|
Lines 1-12
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2009, 2015 Fabian Steeg and others. |
2 |
* Copyright (c) 2009, 2016 itemis AG and others. |
|
|
3 |
* |
| 3 |
* All rights reserved. This program and the accompanying materials |
4 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
6 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
8 |
* |
| 8 |
* Contributors: |
9 |
* Contributors: |
| 9 |
* Fabian Steeg - initial API and implementation (see bug #277380) |
10 |
* Fabian Steeg - initial API and implementation (see bug #277380) |
|
|
11 |
* Tamas Miklossy - use platform specific line separators |
| 10 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
| 11 |
package org.eclipse.gef4.dot.tests; |
13 |
package org.eclipse.gef4.dot.tests; |
| 12 |
|
14 |
|
|
Lines 15-21
Link Here
|
| 15 |
import static org.junit.Assert.assertTrue; |
17 |
import static org.junit.Assert.assertTrue; |
| 16 |
|
18 |
|
| 17 |
import java.io.File; |
19 |
import java.io.File; |
| 18 |
import java.io.FileNotFoundException; |
|
|
| 19 |
import java.util.Scanner; |
20 |
import java.util.Scanner; |
| 20 |
|
21 |
|
| 21 |
import org.eclipse.gef4.dot.internal.DotAttributes; |
22 |
import org.eclipse.gef4.dot.internal.DotAttributes; |
|
Lines 63-69
Link Here
|
| 63 |
"Generated file " + new File(OUTPUT, fileName).getName() //$NON-NLS-1$ |
64 |
"Generated file " + new File(OUTPUT, fileName).getName() //$NON-NLS-1$ |
| 64 |
+ " must exist!", |
65 |
+ " must exist!", |
| 65 |
new File(OUTPUT, fileName).exists()); |
66 |
new File(OUTPUT, fileName).exists()); |
| 66 |
String dotRead = read(new File(OUTPUT, fileName)); |
67 |
String dotRead = DotFileUtils.read(new File(OUTPUT, fileName)); |
| 67 |
Assert.assertEquals("File output and String output should be equal;", //$NON-NLS-1$ |
68 |
Assert.assertEquals("File output and String output should be equal;", //$NON-NLS-1$ |
| 68 |
dot, dotRead); |
69 |
dot, dotRead); |
| 69 |
} |
70 |
} |
|
Lines 121-140
Link Here
|
| 121 |
} |
122 |
} |
| 122 |
scanner.close(); |
123 |
scanner.close(); |
| 123 |
} |
124 |
} |
| 124 |
|
|
|
| 125 |
private String read(final File file) { |
| 126 |
try { |
| 127 |
Scanner scanner = new Scanner(file); |
| 128 |
StringBuilder builder = new StringBuilder(); |
| 129 |
while (scanner.hasNextLine()) { |
| 130 |
builder.append(scanner.nextLine() + "\n"); //$NON-NLS-1$ |
| 131 |
} |
| 132 |
scanner.close(); |
| 133 |
return builder.toString(); |
| 134 |
} catch (FileNotFoundException e) { |
| 135 |
e.printStackTrace(); |
| 136 |
} |
| 137 |
return null; |
| 138 |
} |
| 139 |
|
| 140 |
} |
125 |
} |