1
/*******************************************************************************
2
* Copyright (c) 2009 Red Hat, Inc.
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
* Red Hat - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.linuxtools.rpm.ui.editor.tests.actions;
13
import static org.junit.Assert.assertEquals;
15
import java.text.MessageFormat;
16
import java.text.SimpleDateFormat;
17
import java.util.Date;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.linuxtools.internal.rpm.ui.editor.actions.SpecfileChangelogFormatter;
21
import org.eclipse.linuxtools.rpm.ui.editor.tests.FileTestCase;
22
import org.eclipse.ui.IEditorPart;
23
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.ide.IDE;
25
import org.junit.Before;
26
import org.junit.Test;
28
public class SpecfileChangelogFormatterTest extends FileTestCase {
30
private static final String USER_MAIL = "someone@redhat.com";
31
private static final String USER_NAME = "Alexander Kurtakov";
32
private SpecfileChangelogFormatter formatter;
33
private IEditorPart editor;
34
public final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("EEE MMM d yyyy");
38
public void setUp() throws CoreException {
40
newFile("%changelog");
41
editor = IDE.openEditor(PlatformUI.getWorkbench()
42
.getActiveWorkbenchWindow().getActivePage(), testFile,
43
"org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor");
44
formatter = new SpecfileChangelogFormatter();
48
public void testFormatDateLine() {
49
String expectedLine = MessageFormat
50
.format("* {0} {1} <{2}> {3}{4}-{5}", SIMPLE_DATE_FORMAT.format(new Date()), //$NON-NLS-1$
51
USER_NAME, USER_MAIL, "", "0", "0");
52
assertEquals(expectedLine,
53
formatter.formatDateLine(USER_NAME, USER_MAIL));
57
public void testMergeChangelogStringStringStringIEditorPartStringString() {
58
// TODO find how to test this
59
formatter.mergeChangelog("proba", "", editor, "", "");