Skip to content

Commit

Permalink
Add library group for extra libraries to non-App Engine standard proj…
Browse files Browse the repository at this point in the history
…ects (#3207)
  • Loading branch information
chanseokoh authored Jul 3, 2018
1 parent 441ea13 commit 235acbd
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.hamcrest.Matchers;
import org.junit.Test;
Expand Down Expand Up @@ -200,7 +199,7 @@ public void testObjectify6LibraryConfig() throws URISyntaxException {
Library objectifyLibrary = CloudLibraries.getLibrary("objectify6");
assertThat(objectifyLibrary.getId(), is("objectify6"));
assertThat(objectifyLibrary.getName(), is("Objectify"));
assertThat(objectifyLibrary.getGroups().get(0), is("flexible"));
assertThat(objectifyLibrary.getGroups().get(0), is("non-appengine-standard"));
assertThat(objectifyLibrary.getSiteUri(),
is(new URI("https://github.com/objectify/objectify/wiki")));
assertTrue(objectifyLibrary.isExport());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void testGetLibrary() {
@Test
public void testGetLibraryObjectify6() {
Library library = CloudLibraries.getLibrary("objectify6");
Assert.assertEquals("flexible", library.getGroups().get(0));
Assert.assertEquals("non-appengine-standard", library.getGroups().get(0));
Assert.assertEquals("Objectify", library.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.google.cloud.tools.eclipse.appengine.facets.AppEngineFlexWarFacet;
import com.google.cloud.tools.eclipse.appengine.facets.AppEngineStandardFacet;
import com.google.cloud.tools.eclipse.appengine.libraries.LibraryClasspathContainer;
import com.google.cloud.tools.eclipse.appengine.libraries.model.CloudLibraries;
Expand Down Expand Up @@ -117,6 +118,33 @@ public void testAppEngineLibraries_missingOnPlainJavaProject() {
Matchers.not(Matchers.hasKey(CloudLibraries.APP_ENGINE_STANDARD_GROUP)));
}

@Test
public void testNonAppEngineLibraries_foundOnPlainJavaProject() {
IJavaProject javaProject = plainJavaProjectCreator.getJavaProject();
page.initialize(javaProject, null);
page.createControl(shellTestResource.getShell());
assertThat(page.libraryGroups, Matchers.hasKey(CloudLibraries.NON_APP_ENGINE_STANDARD_GROUP));
}

@Test
public void testNonAppEngineLibraries_foundOnAppEngineFlexProject() {
IJavaProject javaProject = plainJavaProjectCreator
.withFacets(WebFacetUtils.WEB_31, AppEngineFlexWarFacet.FACET_VERSION).getJavaProject();
page.initialize(javaProject, null);
page.createControl(shellTestResource.getShell());
assertThat(page.libraryGroups, Matchers.hasKey(CloudLibraries.NON_APP_ENGINE_STANDARD_GROUP));
}

@Test
public void testNonAppEngineLibraries_missingOnAppEngineStandardProject() {
IJavaProject javaProject = plainJavaProjectCreator
.withFacets(WebFacetUtils.WEB_25, AppEngineStandardFacet.JRE7).getJavaProject();
page.initialize(javaProject, null);
page.createControl(shellTestResource.getShell());
assertThat(page.libraryGroups,
Matchers.not(Matchers.hasKey(CloudLibraries.NON_APP_ENGINE_STANDARD_GROUP)));
}

@Test
public void testSelectionMaintained() {
// explicitly configure App Engine and GCP libraries
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setUp() {
shell = shellTestResource.getShell();
shell.setLayout(new FillLayout());
librariesSelector = new LibrarySelectorGroup(
shell, CloudLibraries.APP_ENGINE_FLEXIBLE_GROUP, "xxx"); //$NON-NLS-1$
shell, CloudLibraries.NON_APP_ENGINE_STANDARD_GROUP, "xxx"); //$NON-NLS-1$
shell.open();
objectifyButton = getButton("objectify6");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public CloudLibrariesPage() {

@Override
public void initialize(IJavaProject javaProject, IClasspathEntry[] currentEntries) {
this.project = javaProject;
project = javaProject;
isMavenProject = MavenUtils.hasMavenNature(javaProject.getProject());

// As we don't support multiple containers, we pretend to edit the existing container if
Expand All @@ -105,6 +105,9 @@ public void initialize(IJavaProject javaProject, IClasspathEntry[] currentEntrie
if (AppEngineStandardFacet.getProjectFacetVersion(javaProject.getProject()) != null) {
groups.put(CloudLibraries.APP_ENGINE_STANDARD_GROUP,
Messages.getString("appengine-title")); //$NON-NLS-1$
} else {
groups.put(CloudLibraries.NON_APP_ENGINE_STANDARD_GROUP,
Messages.getString("non-appengine-title")); //$NON-NLS-1$
}
groups.put(CloudLibraries.CLIENT_APIS_GROUP,
Messages.getString("clientapis-title")); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ apiclientlibrariespage-description=Additional jars for applications using Google
cloud-platform-libraries-title=Google Cloud Platform Libraries
appengine-title=App Engine Standard Libraries
clientapis-title=Cloud Client Libraries for Java
non-appengine-title=Other Libraries
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

<library
id="objectify6"
group="flexible"
group="non-appengine-standard"
name="Objectify"
tooltip="%objectify.tooltip"
dependencies="include"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ public class CloudLibraries {
public static final String MASTER_CONTAINER_ID = "master-container";

/**
* Library files for App Engine Standard environment applications; specifically
* Objectify, App Engine API, and Google Cloud Endpoints.
* Library files for App Engine standard environment applications; specifically
* Objectify 5, App Engine API 1.0 SDK, and Google Cloud Endpoints.
*/
public static final String APP_ENGINE_STANDARD_GROUP = "appengine"; //$NON-NLS-1$

/**
* Library files for App Engine Flexible environment applications; specifically
* Objectify.
* Non-App Engine standard environment application libraries files that do not fall into the
* category of Google Cloud Client Library for Java. Includes Objectify 6.
*/
public static final String APP_ENGINE_FLEXIBLE_GROUP = "flexible"; //$NON-NLS-1$
public static final String NON_APP_ENGINE_STANDARD_GROUP = "non-appengine-standard"; //$NON-NLS-1$

/**
* Library files for the Google Cloud Client Library for Java. E.g.
* Stackdriver Logging, Cloud Datastore, Cloud Storage, Cloud Translation, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void setHelp(Composite container) {

@Override
protected String getSupportedLibrariesGroup() {
return CloudLibraries.APP_ENGINE_FLEXIBLE_GROUP;
return CloudLibraries.NON_APP_ENGINE_STANDARD_GROUP;
}

@Override
Expand Down

0 comments on commit 235acbd

Please sign in to comment.