Skip to content

Commit 7554022

Browse files
authored
some tests for AppEngineLibrariesPage (#1511)
* some tests for AppEngineLibrariesPage * some tests for AppEngineLibrariesPage * copyright * spacing * remove unneeded final * line length * formatting
1 parent 61fb559 commit 7554022

6 files changed

Lines changed: 65 additions & 10 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2017 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.tools.eclipse.appengine.libraries.ui;
18+
19+
import org.junit.Assert;
20+
import org.junit.Test;
21+
22+
public class AppEngineLibrariesPageTest {
23+
24+
private AppEngineLibrariesPage page = new AppEngineLibrariesPage();
25+
26+
@Test
27+
public void testConstructor() {
28+
Assert.assertEquals("App Engine Standard Environment Libraries", page.getTitle());
29+
Assert.assertNull(page.getMessage());
30+
Assert.assertNull(page.getErrorMessage());
31+
Assert.assertEquals(
32+
"Additional jars commonly used in App Engine Standard Environment applications",
33+
page.getDescription());
34+
Assert.assertNotNull(page.getImage());
35+
}
36+
37+
@Test
38+
public void testFinish() {
39+
Assert.assertTrue(page.finish());
40+
}
41+
42+
@Test
43+
public void testGetSelection() {
44+
Assert.assertNull(page.getSelection());
45+
}
46+
47+
}

plugins/com.google.cloud.tools.eclipse.appengine.libraries.ui.test/src/com/google/cloud/tools/eclipse/appengine/libraries/ui/MessagesTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,12 @@ public void testDescription() {
3232
"Additional jars commonly used in App Engine Standard Environment applications",
3333
Messages.getString("description"));
3434
}
35+
36+
37+
@Test
38+
public void testUnknownMessage() {
39+
Assert.assertEquals("!foo.bar!", Messages.getString("foo.bar"));
40+
}
41+
3542

3643
}

plugins/com.google.cloud.tools.eclipse.appengine.libraries.ui/src/com/google/cloud/tools/eclipse/appengine/libraries/ui/AppEngineLibrariesPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public class AppEngineLibrariesPage extends WizardPage implements IClasspathCont
5252

5353
public AppEngineLibrariesPage() {
5454
super("appengine-libraries-page"); //$NON-NLS-1$
55-
setTitle(Messages.getString("title"));
56-
setDescription(Messages.getString("description"));
55+
setTitle(Messages.getString("title")); //$NON-NLS-1$
56+
setDescription(Messages.getString("description")); //$NON-NLS-1$
5757
setImageDescriptor(AppEngineImages.appEngine(64));
5858
}
5959

plugins/com.google.cloud.tools.eclipse.appengine.libraries/src/com/google/cloud/tools/eclipse/appengine/libraries/repository/LibraryClasspathContainerResolverService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,17 @@ private LibraryClasspathContainer resolveLibraryFiles(IJavaProject javaProject,
183183

184184
private IClasspathEntry resolveLibraryFileAttachSourceAsync(IJavaProject javaProject,
185185
IPath containerPath,
186-
final LibraryFile libraryFile,
186+
LibraryFile libraryFile,
187187
List<Job> sourceAttacherJobs,
188-
final IProgressMonitor monitor)
188+
IProgressMonitor monitor)
189189
throws CoreException {
190-
final Artifact artifact = repositoryService.resolveArtifact(libraryFile, monitor);
190+
Artifact artifact = repositoryService.resolveArtifact(libraryFile, monitor);
191191
IPath libraryPath = new Path(artifact.getFile().getAbsolutePath());
192192
IPath sourceAttachmentPath = null;
193193
Job job = createSourceAttacherJob(javaProject, containerPath, libraryFile,
194194
monitor, artifact, libraryPath);
195195
sourceAttacherJobs.add(job);
196-
final IClasspathEntry newLibraryEntry =
196+
IClasspathEntry newLibraryEntry =
197197
JavaCore.newLibraryEntry(libraryPath,
198198
sourceAttachmentPath,
199199
null /* sourceAttachmentRootPath */,

plugins/com.google.cloud.tools.eclipse.appengine.libraries/src/com/google/cloud/tools/eclipse/appengine/libraries/repository/M2RepositoryService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
* artifacts and store them in the local Maven repository pointed to by M2Eclipse's M2_REPO
4040
* variable.
4141
* <p>
42-
* In case <code>libraryfile.getSourceUri()</code> is null, M2Eclipse is used to resolve the source
43-
* artifact by using the "sources" classifier with the binary artifact's {@link MavenCoordinates}.;
42+
* In case <code>libraryfile.getSourceUri()</code> is null, M2Eclipse resolves the source
43+
* artifact by using the "sources" classifier with the binary artifact's {@link MavenCoordinates}.
4444
*/
4545
@Component
4646
public class M2RepositoryService implements ILibraryRepositoryService {
@@ -92,7 +92,7 @@ private static IPath getDownloadedSourceLocation(MavenCoordinates mavenCoordinat
9292
IPath downloadFolder = MavenHelper.bundleStateBasedMavenFolder(mavenCoordinates);
9393
return new FileDownloader(downloadFolder).download(sourceUrl, monitor);
9494
} catch (IOException e) {
95-
// source file is failed to download, this is not an error
95+
// source file failed to download; this is not an error
9696
return null;
9797
}
9898
}

plugins/com.google.cloud.tools.eclipse.appengine.libraries/src/com/google/cloud/tools/eclipse/appengine/libraries/repository/MavenHelper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ private ArtifactRepository getCustomRepository(String repository) throws CoreExc
9191
* @return the location of the download folder, may not exist
9292
*/
9393
public static IPath bundleStateBasedMavenFolder(MavenCoordinates mavenCoordinates) {
94-
Preconditions.checkArgument(!mavenCoordinates.getVersion().equals(MavenCoordinates.LATEST_VERSION));
94+
Preconditions.checkArgument(
95+
!mavenCoordinates.getVersion().equals(MavenCoordinates.LATEST_VERSION));
9596
File downloadedSources =
9697
Platform.getStateLocation(FrameworkUtil.getBundle(MavenHelper.class))
9798
.append("downloads")

0 commit comments

Comments
 (0)