Added
Link Here
|
1 |
/* |
2 |
* Copyright (c) 2006 Borland Software Corporation |
3 |
* |
4 |
* All rights reserved. This program and the accompanying materials |
5 |
* are made available under the terms of the Eclipse Public License v1.0 |
6 |
* which accompanies this distribution, and is available at |
7 |
* http://www.eclipse.org/legal/epl-v10.html |
8 |
* |
9 |
* Contributors: |
10 |
* Michael Golubev (Borland) - initial API and implementation |
11 |
*/ |
12 |
|
13 |
package org.eclipse.gmf.codegen.reconciler.test; |
14 |
|
15 |
import java.io.IOException; |
16 |
|
17 |
import junit.framework.TestCase; |
18 |
|
19 |
import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator; |
20 |
import org.eclipse.gmf.codegen.gmfgen.GenPlugin; |
21 |
import org.eclipse.gmf.codegen.reconciler.Reconciler; |
22 |
import org.eclipse.gmf.internal.codegen.reconciler.GMFGenConfig; |
23 |
|
24 |
public class ReconcileTaipanTest extends TestCase { |
25 |
public void testLoadGMFGen() throws Exception { |
26 |
GenEditorGenerator original = loadTaipanGMFGen(); |
27 |
assertNotNull(original); |
28 |
GenEditorGenerator copy = loadTaipanGMFGen(); |
29 |
assertNotNull(copy); |
30 |
|
31 |
assertFalse(original == copy); |
32 |
assertFalse(original.equals(copy)); |
33 |
|
34 |
assertEquals(original.getCopyrightText(), copy.getCopyrightText()); |
35 |
assertEquals(original.isSameFileForDiagramAndModel(), copy.isSameFileForDiagramAndModel()); |
36 |
assertEquals(original.getPackageNamePrefix(), copy.getPackageNamePrefix()); |
37 |
|
38 |
final String NEW_VALUE = "New Value"; |
39 |
copy.setCopyrightText(NEW_VALUE); |
40 |
assertEquals(copy.getCopyrightText(), NEW_VALUE); |
41 |
assertFalse(copy.getCopyrightText().equals(original.getCopyrightText())); |
42 |
} |
43 |
|
44 |
public void testReconcileDeepElementWithAlwaysMatcher() throws Exception { |
45 |
GenPlugin old = loadTaipanGMFGen().getPlugin(); |
46 |
GenPlugin current = loadTaipanGMFGen().getPlugin(); |
47 |
|
48 |
assertNotNull(old.getProvider()); |
49 |
assertNotNull(old.getVersion()); |
50 |
|
51 |
final String NEW_PROVIDER = "NewProviderValue"; |
52 |
final String NEW_VERSION = "NewVersionValue"; |
53 |
|
54 |
old.setProvider(NEW_PROVIDER); |
55 |
old.setVersion(NEW_VERSION); |
56 |
|
57 |
getReconciler().reconcileTree(current, old); |
58 |
|
59 |
assertEquals(NEW_PROVIDER, current.getProvider()); |
60 |
assertEquals(NEW_VERSION, current.getVersion()); |
61 |
} |
62 |
|
63 |
public void testReconcileGenEditorGenerator() throws Exception { |
64 |
GenEditorGenerator old = loadTaipanGMFGen(); |
65 |
GenEditorGenerator current = loadTaipanGMFGen(); |
66 |
|
67 |
old.setCopyrightText("AAA"); |
68 |
old.setPackageNamePrefix("BBB"); |
69 |
old.setDiagramFileExtension("CCC"); |
70 |
|
71 |
boolean sameFile = !old.isSameFileForDiagramAndModel(); |
72 |
old.setSameFileForDiagramAndModel(sameFile); |
73 |
|
74 |
//we do not reconcile this now |
75 |
old.setTemplateDirectory("DDD"); |
76 |
assertEquals("DDD", old.getTemplateDirectory()); |
77 |
|
78 |
getReconciler().reconcileTree(current, old); |
79 |
|
80 |
assertEquals("AAA", current.getCopyrightText()); |
81 |
assertEquals("BBB", current.getPackageNamePrefix()); |
82 |
assertEquals("CCC", current.getDiagramFileExtension()); |
83 |
assertEquals(sameFile, current.isSameFileForDiagramAndModel()); |
84 |
|
85 |
assertEquals("DDD", old.getTemplateDirectory()); |
86 |
assertFalse("DDD".equals(current.getTemplateDirectory())); |
87 |
} |
88 |
|
89 |
private Reconciler getReconciler(){ |
90 |
return new Reconciler(new GMFGenConfig()); |
91 |
} |
92 |
|
93 |
private GenEditorGenerator loadTaipanGMFGen() throws IOException{ |
94 |
return new TaipanSuite().createTaipanEditorGenerator(); |
95 |
} |
96 |
} |