View | Details | Raw Unified | Return to bug 378047 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.releng.tests/.classpath (-1 / +1 lines)
Lines 2-7 Link Here
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
5
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)a/bundles/org.eclipse.releng.tests/.settings/org.eclipse.jdt.core.prefs (-7 / +6 lines)
Lines 1-4 Link Here
1
#Fri Feb 11 09:19:22 CET 2011
2
eclipse.preferences.version=1
1
eclipse.preferences.version=1
3
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
2
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
4
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
3
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
Lines 8-23 org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch Link Here
8
org.eclipse.jdt.core.circularClasspath=error
7
org.eclipse.jdt.core.circularClasspath=error
9
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
8
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
10
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
9
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
11
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
10
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
12
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
11
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
13
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
12
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
14
org.eclipse.jdt.core.compiler.compliance=1.4
13
org.eclipse.jdt.core.compiler.compliance=1.5
15
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
14
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
16
org.eclipse.jdt.core.compiler.debug.localVariable=generate
15
org.eclipse.jdt.core.compiler.debug.localVariable=generate
17
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
16
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
18
org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
17
org.eclipse.jdt.core.compiler.maxProblemPerUnit=100
19
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
18
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
20
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
19
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
21
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
20
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
22
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
21
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
23
org.eclipse.jdt.core.compiler.problem.deadCode=error
22
org.eclipse.jdt.core.compiler.problem.deadCode=error
Lines 26-32 org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled Link Here
26
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
25
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
27
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
26
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
28
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
27
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
29
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
28
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
30
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
29
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
31
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
30
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
32
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
31
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
Lines 87-92 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa Link Here
87
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
86
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
88
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
87
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
89
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
88
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
90
org.eclipse.jdt.core.compiler.source=1.3
89
org.eclipse.jdt.core.compiler.source=1.5
91
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
90
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
92
org.eclipse.jdt.core.incompleteClasspath=error
91
org.eclipse.jdt.core.incompleteClasspath=error
(-)a/bundles/org.eclipse.releng.tests/META-INF/MANIFEST.MF (-2 / +6 lines)
Lines 8-13 Bundle-Vendor: %Plugin.providerName Link Here
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Require-Bundle: org.eclipse.core.runtime,
9
Require-Bundle: org.eclipse.core.runtime,
10
 org.eclipse.pde.tools.versioning,
10
 org.eclipse.pde.tools.versioning,
11
 org.junit
11
 org.junit,
12
 org.eclipse.jgit;bundle-version="1.3.0",
13
 org.eclipse.core.resources,
14
 org.eclipse.egit.core;bundle-version="1.3.0",
15
 org.eclipse.releng.tools;bundle-version="3.6.100"
12
Export-Package: org.eclipse.releng.tests
16
Export-Package: org.eclipse.releng.tests
13
Bundle-RequiredExecutionEnvironment: J2SE-1.4
17
Bundle-RequiredExecutionEnvironment: J2SE-1.5
(-)a/bundles/org.eclipse.releng.tests/src/org/eclipse/releng/tests/GitCopyrightAdapterTest.java (+150 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 IBM Corporation and others.
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
7
 *
8
 * Contributors:
9
 *     Tomasz Zarna <Tomasz.Zarna@pl.ibm.com> - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.releng.tests;
12
13
import static org.junit.Assert.assertEquals;
14
15
import java.io.ByteArrayInputStream;
16
import java.io.File;
17
import java.text.ParseException;
18
import java.text.SimpleDateFormat;
19
import java.util.Date;
20
21
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.IProjectDescription;
24
import org.eclipse.core.resources.IResource;
25
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.IProgressMonitor;
28
import org.eclipse.core.runtime.NullProgressMonitor;
29
import org.eclipse.core.runtime.Path;
30
import org.eclipse.egit.core.op.ConnectProviderOperation;
31
import org.eclipse.jgit.api.Git;
32
import org.eclipse.jgit.lib.Constants;
33
import org.eclipse.jgit.lib.PersonIdent;
34
import org.eclipse.jgit.lib.Repository;
35
import org.eclipse.jgit.util.FileUtils;
36
import org.eclipse.releng.tools.git.GitCopyrightAdapter;
37
import org.junit.After;
38
import org.junit.Before;
39
import org.junit.Test;
40
41
public class GitCopyrightAdapterTest extends LocalDiskRepositoryTest {
42
43
	private static final IProgressMonitor NULL_MONITOR = new NullProgressMonitor();
44
45
	private static final String PROJECT_NAME = "Project";
46
47
	private static final String FILE1_NAME = "Foo.java";
48
49
	private static final String FILE2_NAME = "Bar.java";
50
51
	private Repository db;
52
53
	private File trash;
54
55
	private File gitDir;
56
57
	private IProject project;
58
59
	private IFile file1;
60
61
	@Override
62
	@Before
63
	public void setUp() throws Exception {
64
		super.setUp();
65
		db = createWorkRepository();
66
		trash = db.getWorkTree();
67
		gitDir = new File(trash, Constants.DOT_GIT);
68
		project = createProject(PROJECT_NAME);
69
		file1 = project.getFile(FILE1_NAME);
70
		connect();
71
	}
72
73
	@Override
74
	@After
75
	public void tearDown() throws Exception {
76
		if (project.exists())
77
			project.delete(true, true, NULL_MONITOR);
78
		if (gitDir.exists())
79
			FileUtils.delete(gitDir, FileUtils.RECURSIVE | FileUtils.RETRY);
80
		super.tearDown();
81
	}
82
83
	@Test
84
	public void testLastModifiedYear() throws Exception {
85
		final Git git = new Git(db);
86
		git.add().addFilepattern(PROJECT_NAME + "/" + FILE1_NAME).call();
87
		final PersonIdent committer2011 = new PersonIdent(committer,
88
				getDateForYear(2011));
89
		git.commit().setMessage("old commit").setCommitter(committer2011)
90
				.call();
91
		git.add().addFilepattern(PROJECT_NAME + "/" + FILE2_NAME).call();
92
		git.commit().setMessage("new commit").call();
93
94
		final GitCopyrightAdapter adapter = new GitCopyrightAdapter(
95
				new IResource[] { project });
96
		adapter.initialize(NULL_MONITOR);
97
		final int lastModifiedYear = adapter.getLastModifiedYear(file1,
98
				NULL_MONITOR);
99
100
		assertEquals(2011, lastModifiedYear);
101
	}
102
103
	@Test
104
	public void testCopyrightUpdateComment() throws Exception {
105
		final Git git = new Git(db);
106
		git.add().addFilepattern(PROJECT_NAME + "/" + FILE1_NAME).call();
107
		git.commit().setMessage("copyright update").call();
108
109
		final GitCopyrightAdapter adapter = new GitCopyrightAdapter(
110
				new IResource[] { project });
111
		adapter.initialize(NULL_MONITOR);
112
		final int lastModifiedYear = adapter.getLastModifiedYear(file1,
113
				NULL_MONITOR);
114
115
		assertEquals(0, lastModifiedYear);
116
	}
117
118
	private IProject createProject(String name) throws Exception {
119
		final IProject project = ResourcesPlugin.getWorkspace().getRoot()
120
				.getProject(name);
121
		if (project.exists())
122
			project.delete(true, null);
123
		final IProjectDescription desc = ResourcesPlugin.getWorkspace()
124
				.newProjectDescription(name);
125
		desc.setLocation(new Path(new File(db.getWorkTree(), name).getPath()));
126
		project.create(desc, null);
127
		project.open(null);
128
129
		final IFile file1 = project.getFile(FILE1_NAME);
130
		file1.create(
131
				new ByteArrayInputStream("Hello, world".getBytes(project
132
						.getDefaultCharset())), false, null);
133
134
		final IFile file2 = project.getFile(FILE2_NAME);
135
		file2.create(
136
				new ByteArrayInputStream("Hi there".getBytes(project
137
						.getDefaultCharset())), false, null);
138
		return project;
139
	}
140
141
	private void connect() throws CoreException {
142
		new ConnectProviderOperation(project, gitDir).execute(null);
143
	}
144
145
	private Date getDateForYear(int year) throws ParseException {
146
		final SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
147
		return formatter.parse(Integer.toString(year) + "/6/30");
148
	}
149
150
}
(-)a/bundles/org.eclipse.releng.tests/src/org/eclipse/releng/tests/LocalDiskRepositoryTest.java (+136 lines)
Added Link Here
1
/*
2
 * Copyright (C) 2009-2010, Google Inc.
3
 * Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
4
 * Copyright (C) 2007, Shawn O. Pearce <spearce@spearce.org>
5
 * and other copyright owners as documented in the project's IP log.
6
 *
7
 * This program and the accompanying materials are made available
8
 * under the terms of the Eclipse Distribution License v1.0 which
9
 * accompanies this distribution, is reproduced below, and is
10
 * available at http://www.eclipse.org/org/documents/edl-v10.php
11
 *
12
 * All rights reserved.
13
 *
14
 * Redistribution and use in source and binary forms, with or
15
 * without modification, are permitted provided that the following
16
 * conditions are met:
17
 *
18
 * - Redistributions of source code must retain the above copyright
19
 *   notice, this list of conditions and the following disclaimer.
20
 *
21
 * - Redistributions in binary form must reproduce the above
22
 *   copyright notice, this list of conditions and the following
23
 *   disclaimer in the documentation and/or other materials provided
24
 *   with the distribution.
25
 *
26
 * - Neither the name of the Eclipse Foundation, Inc. nor the
27
 *   names of its contributors may be used to endorse or promote
28
 *   products derived from this software without specific prior
29
 *   written permission.
30
 *
31
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
32
 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
33
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
34
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
36
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
38
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
39
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
40
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
42
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
43
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44
 */
45
package org.eclipse.releng.tests;
46
47
import static org.junit.Assert.assertFalse;
48
49
import java.io.File;
50
import java.io.IOException;
51
import java.util.ArrayList;
52
import java.util.List;
53
54
import org.eclipse.jgit.lib.Constants;
55
import org.eclipse.jgit.lib.PersonIdent;
56
import org.eclipse.jgit.lib.Repository;
57
import org.eclipse.jgit.lib.RepositoryCache;
58
import org.eclipse.jgit.storage.file.FileRepository;
59
import org.junit.After;
60
import org.junit.Before;
61
62
/**
63
 * An extract from org.eclipse.jgit.junit.LocalDiskRepositoryTestCase
64
 *
65
 */
66
public class LocalDiskRepositoryTest {
67
	private static int testCount;
68
	protected PersonIdent committer;
69
	private final File trash = new File(new File("target"), "trash");
70
	private final List<Repository> toClose = new ArrayList<Repository>();
71
72
	@Before
73
	public void setUp() throws Exception {
74
		committer = new PersonIdent("J. Committer", "jcommitter@example.com");
75
	}
76
77
	@After
78
	public void tearDown() throws Exception {
79
		RepositoryCache.clear();
80
		for (Repository r : toClose)
81
			r.close();
82
		toClose.clear();
83
	}
84
85
	/**
86
	 * Creates a new empty repository within a new empty working directory.
87
	 *
88
	 * @return the newly created repository, opened for access
89
	 * @throws IOException
90
	 *             the repository could not be created in the temporary area
91
	 */
92
	protected FileRepository createWorkRepository() throws IOException {
93
		return createRepository(false /* not bare */);
94
	}
95
96
	/**
97
	 * Creates a new empty repository.
98
	 *
99
	 * @param bare
100
	 *            true to create a bare repository; false to make a repository
101
	 *            within its working directory
102
	 * @return the newly created repository, opened for access
103
	 * @throws IOException
104
	 *             the repository could not be created in the temporary area
105
	 */
106
	private FileRepository createRepository(boolean bare) throws IOException {
107
		File gitdir = createUniqueTestGitDir(bare);
108
		FileRepository db = new FileRepository(gitdir);
109
		assertFalse(gitdir.exists());
110
		db.create();
111
		toClose.add(db);
112
		return db;
113
	}
114
115
	/**
116
	 * Creates a new unique directory for a test repository
117
	 *
118
	 * @param bare
119
	 *            true for a bare repository; false for a repository with a
120
	 *            working directory
121
	 * @return a unique directory for a test repository
122
	 * @throws IOException
123
	 */
124
	protected File createUniqueTestGitDir(boolean bare) throws IOException {
125
		String gitdirName = createUniqueTestFolderPrefix();
126
		if (!bare)
127
			gitdirName += "/";
128
		gitdirName += Constants.DOT_GIT;
129
		File gitdir = new File(trash, gitdirName);
130
		return gitdir.getCanonicalFile();
131
	}
132
133
	private String createUniqueTestFolderPrefix() {
134
		return "test" + (System.currentTimeMillis() + "_" + (testCount++));
135
	}
136
}

Return to bug 378047