-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Cleaned up StandardDeployJob and added step to auto-open the deployed app in a browser * Moved StandardDeployJob.DeployOutput and StandardDeployJob#parseDeployJsonOutput into AppEngineDeployUtil * Minor clean up * When creating DeployOutput check for a valid version object * Removed duplicate version check * Minor changes per PR comments * Separated StdOutLineListener for the deploy and staging process * Created a utility function for lauching a web browser with a specified url. * Utilizing WorkbenchUtil#openInBrowser * Minor changes per PR comments * Created a private constructor for AppEngineDeployOutput so that the only way to create an instance is on a successful call to AppEngineDeployOutput#parse * Changed variable name * Nit * Created a VersionNotFoundException to be thrown when we cannot determine the version of the deployed application * Created a convience method WorkbenchUtil#openInBrowser(IWorkbench workbench, String urlPath) * Updated javadoc for WorkbenchUtil#openInBrowserInUiThread and WorkbenchUtil#openInBrowser
- Loading branch information
1 parent
d337a34
commit 717ab82
Showing
17 changed files
with
439 additions
and
135 deletions.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
...y.test/src/com/google/cloud/tools/eclipse/appengine/deploy/AppEngineDeployOutputTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright 2017 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.tools.eclipse.appengine.deploy; | ||
|
||
import com.google.gson.JsonParseException; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Unit tests for {@link AppEngineDeployOutput} | ||
*/ | ||
public class AppEngineDeployOutputTest { | ||
@Test | ||
public void testDeployOutputJsonParsingOneVersion() { | ||
String jsonOutput = | ||
"{\n" + | ||
" \"configs\": [],\n" + | ||
" \"versions\": [\n" + | ||
" {\n" + | ||
" \"id\": \"20160429t112518\",\n" + | ||
" \"last_deployed_time\": null,\n" + | ||
" \"project\": \"some-project\",\n" + | ||
" \"service\": \"default\",\n" + | ||
" \"traffic_split\": null,\n" + | ||
" \"version\": null\n" + | ||
" }\n" + | ||
" ]\n" + | ||
"}\n"; | ||
|
||
AppEngineDeployOutput deployOutput = | ||
AppEngineDeployOutput.parse(jsonOutput); | ||
Assert.assertEquals("20160429t112518", deployOutput.getVersion()); | ||
Assert.assertEquals("default", deployOutput.getService()); | ||
} | ||
|
||
@Test | ||
public void testDeployOutputJsonParsingTwoVersions() { | ||
String jsonOutput = | ||
"{\n" + | ||
" \"configs\": [],\n" + | ||
" \"versions\": [\n" + | ||
" {\n" + | ||
" \"id\": \"20160429t112518\",\n" + | ||
" \"last_deployed_time\": null,\n" + | ||
" \"project\": \"some-project\",\n" + | ||
" \"service\": \"default\",\n" + | ||
" \"traffic_split\": null,\n" + | ||
" \"version\": null\n" + | ||
" },\n" + | ||
" {\n" + | ||
" \"id\": \"20160429t112518\",\n" + | ||
" \"last_deployed_time\": null,\n" + | ||
" \"project\": \"some-project\",\n" + | ||
" \"service\": \"default\",\n" + | ||
" \"traffic_split\": null,\n" + | ||
" \"version\": null\n" + | ||
" }\n" + | ||
" ]\n" + | ||
"}\n"; | ||
|
||
try { | ||
AppEngineDeployOutput.parse(jsonOutput); | ||
Assert.fail("Failure to throw exception when parsing deploy output with more that one version entry"); | ||
} catch (JsonParseException e) { | ||
// Success! Should throw a JsonParseException. | ||
} | ||
} | ||
|
||
@Test | ||
public void testDeployOutputJsonParsingOldFormat() { | ||
String jsonOutput = | ||
"{\n" + | ||
" \"default\": \"https://springboot-maven-project.appspot.com\"\n" + | ||
"}\n"; | ||
|
||
try { | ||
AppEngineDeployOutput.parse(jsonOutput); | ||
Assert.fail("Failure to throw exception when parsing deploy output in old format"); | ||
} catch (JsonParseException e) { | ||
// Success! Should throw a JsonParseException. | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...ine.deploy/src/com/google/cloud/tools/eclipse/appengine/deploy/AppEngineDeployOutput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2017 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.tools.eclipse.appengine.deploy; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonParseException; | ||
import java.util.List; | ||
|
||
/** | ||
* Holds de-serialized JSON output of gcloud app deploy. Don't change the field names | ||
* because Gson uses them for automatic de-serialization. | ||
*/ | ||
// TODO: move into appengine-plugins-core | ||
// TODO expand to include other Version attributes | ||
public class AppEngineDeployOutput { | ||
private AppEngineDeployOutput() { | ||
} | ||
|
||
private static class Version { | ||
String id; | ||
String service; | ||
} | ||
|
||
private List<Version> versions; | ||
|
||
/** | ||
* @return version, can be null | ||
*/ | ||
public String getVersion() { | ||
return versions.get(0).id; | ||
} | ||
|
||
/** | ||
* @return service, can be null | ||
*/ | ||
public String getService() { | ||
return versions.get(0).service; | ||
} | ||
|
||
/** | ||
* Parse the raw JSON output of the deployment. | ||
* | ||
* @return the output of gcloud app deploy | ||
* @throws JsonParseException if unable to extract the deploy output information needed | ||
*/ | ||
public static AppEngineDeployOutput parse(String jsonOutput) throws JsonParseException { | ||
AppEngineDeployOutput deployOutput = new Gson().fromJson(jsonOutput, AppEngineDeployOutput.class); | ||
if (deployOutput == null | ||
|| deployOutput.versions == null || deployOutput.versions.size() != 1) { | ||
throw new JsonParseException("Cannot get app version: unexpected gcloud JSON output format"); | ||
} | ||
return deployOutput; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
....deploy/src/com/google/cloud/tools/eclipse/appengine/deploy/VersionNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2017 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.tools.eclipse.appengine.deploy; | ||
|
||
/** | ||
* Thrown if the version of a deployed App Engine application cannot be determined. | ||
*/ | ||
public class VersionNotFoundException extends Exception { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public VersionNotFoundException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.