Skip to content

Commit 2f983b7

Browse files
authored
don't set project ID from new project wizard (#631)
* don't set project ID from new project wizard * version specified on deploy * project ID no longer added to appengine-web.xml * renamed template * empty string to null in assert * unused import * remove version from testdata
1 parent 0ccd2fa commit 2f983b7

File tree

7 files changed

+42
-80
lines changed

7 files changed

+42
-80
lines changed

plugins/com.google.cloud.tools.eclipse.appengine.newproject.test/src/com/google/cloud/tools/eclipse/appengine/newproject/CodeTemplatesTest.java

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
/*******************************************************************************
1+
/*
22
* Copyright 2016 Google Inc. All Rights Reserved.
33
*
4-
* All rights reserved. This program and the accompanying materials are made
5-
* available under the terms of the Eclipse Public License v1.0 which
6-
* accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
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
89
*
910
* Unless required by applicable law or agreed to in writing, software
10-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
* License for the specific language governing permissions and limitations under
13-
* the License.
14-
*******************************************************************************/
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+
*/
1516

1617
package com.google.cloud.tools.eclipse.appengine.newproject;
1718

@@ -94,7 +95,7 @@ public void testMaterialize()
9495
NodeList applicationElements = doc.getDocumentElement().getElementsByTagName("application");
9596
Assert.assertEquals("Must have exactly one application", 1, applicationElements.getLength());
9697
String projectId = applicationElements.item(0).getTextContent();
97-
Assert.assertEquals("TheProjectID", projectId);
98+
Assert.assertEquals("", projectId);
9899

99100
IFile webXml = webinf.getFile("web.xml");
100101
Element root = buildDocument(webXml).getDocumentElement();
@@ -110,22 +111,6 @@ public void testMaterialize()
110111
Element html = buildDocument(htmlFile).getDocumentElement();
111112
Assert.assertEquals("html", html.getNodeName());
112113
}
113-
114-
@Test
115-
public void testNoProjectId()
116-
throws CoreException, ParserConfigurationException, SAXException, IOException {
117-
118-
CodeTemplates.materialize(project, new AppEngineStandardProjectConfig(), monitor);
119-
120-
IFolder src = project.getFolder("src");
121-
IFolder webinf = src.getFolder("main").getFolder("webapp").getFolder("WEB-INF");
122-
IFile appengineWebXml = webinf.getFile("appengine-web.xml");
123-
Document doc = buildDocument(appengineWebXml);
124-
NodeList applicationElements = doc.getDocumentElement().getElementsByTagName("application");
125-
Assert.assertEquals("Must have exactly one application", 1, applicationElements.getLength());
126-
String projectId = applicationElements.item(0).getTextContent();
127-
Assert.assertEquals("", projectId);
128-
}
129114

130115
private Document buildDocument(IFile appengineWebXml)
131116
throws ParserConfigurationException, SAXException, IOException, CoreException {

plugins/com.google.cloud.tools.eclipse.appengine.newproject/src/com/google/cloud/tools/eclipse/appengine/newproject/CodeTemplates.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
/*******************************************************************************
1+
/*
22
* Copyright 2016 Google Inc. All Rights Reserved.
33
*
4-
* All rights reserved. This program and the accompanying materials are made
5-
* available under the terms of the Eclipse Public License v1.0 which
6-
* accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
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
89
*
910
* Unless required by applicable law or agreed to in writing, software
10-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
* License for the specific language governing permissions and limitations under
13-
* the License.
14-
*******************************************************************************/
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+
*/
1516

1617
package com.google.cloud.tools.eclipse.appengine.newproject;
1718

@@ -81,9 +82,8 @@ public static void materialize(IProject project, AppEngineStandardProjectConfig
8182
IFolder webapp = createChildFolder("webapp", main, subMonitor);
8283
IFolder webinf = createChildFolder("WEB-INF", webapp, subMonitor);
8384

84-
Map<String, String> projectId = new HashMap<>();
85-
projectId.put("projectId", config.getAppEngineProjectId());
86-
createChildFile("appengine-web.xml", AppEngineTemplateUtility.APPENGINE_WEB_XML_TEMPLATE, webinf, subMonitor, projectId);
85+
Map<String, String> properties = new HashMap<>();
86+
createChildFile("appengine-web.xml", AppEngineTemplateUtility.APPENGINE_WEB_XML_TEMPLATE, webinf, subMonitor, properties);
8787

8888
Map<String, String> packageMap = new HashMap<>();
8989
String packageValue = config.getPackageName().isEmpty() ? "" : config.getPackageName() + ".";

plugins/com.google.cloud.tools.eclipse.integration.appengine/src/com/google/cloud/tools/eclipse/integration/appengine/NewNativeAppEngineStandardProjectTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.cloud.tools.eclipse.integration.appengine;
1818

19-
import static org.junit.Assert.assertEquals;
2019
import static org.junit.Assert.assertFalse;
2120
import static org.junit.Assert.assertNotNull;
2221
import static org.junit.Assert.assertNull;
@@ -63,7 +62,7 @@ public void testWithPackageAndProjectId() throws Exception {
6362
"src/main/webapp/WEB-INF/web.xml", "src/main/webapp/index.html",};
6463
createAndCheck("appWithPackageAndProjectId", null, "app.engine.test", "my-project-id",
6564
projectFiles);
66-
assertEquals("my-project-id",
65+
assertNull(
6766
SwtBotAppEngineActions.getAppEngineProjectId(project.getFile("src/main/webapp/WEB-INF/appengine-web.xml")));
6867
}
6968

plugins/com.google.cloud.tools.eclipse.util.test/src/com/google/cloud/tools/eclipse/util/templates/appengine/AppEngineTemplateUtilityTest.java

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
/*******************************************************************************
1+
/*
22
* Copyright 2016 Google Inc. All Rights Reserved.
33
*
4-
* All rights reserved. This program and the accompanying materials are made
5-
* available under the terms of the Eclipse Public License v1.0 which
6-
* accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
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
89
*
910
* Unless required by applicable law or agreed to in writing, software
10-
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12-
* License for the specific language governing permissions and limitations under
13-
* the License.
14-
*******************************************************************************/
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+
*/
1516

1617
package com.google.cloud.tools.eclipse.util.templates.appengine;
1718

@@ -65,28 +66,14 @@ public void cleanUp() throws CoreException {
6566
}
6667

6768
@Test
68-
public void testCreateFileContent_appengineWebXmlWithProjectId()
69-
throws CoreException, IOException {
70-
String fileLocation = testFile.getLocation().toString();
71-
Map<String, String> dataMap = new HashMap<String, String>();
72-
dataMap.put("projectId", "myProjectId");
73-
AppEngineTemplateUtility.createFileContent(
74-
fileLocation, AppEngineTemplateUtility.APPENGINE_WEB_XML_TEMPLATE, dataMap);
75-
76-
InputStream testFileStream = testFile.getContents(true);
77-
InputStream expectedFileStream = getDataFile("appengineWebXmlWithProjectId.txt");
78-
compareFileContent(expectedFileStream, testFileStream);
79-
}
80-
81-
@Test
82-
public void testCreateFileContent_appengineWebXmlWithoutProjectId()
69+
public void testCreateFileContent_appengineWebXml()
8370
throws CoreException, IOException {
8471
String fileLocation = testFile.getLocation().toString();
8572
AppEngineTemplateUtility.createFileContent(
8673
fileLocation, AppEngineTemplateUtility.APPENGINE_WEB_XML_TEMPLATE, Collections.<String, String> emptyMap());
8774

8875
InputStream testFileStream = testFile.getContents(true);
89-
InputStream expectedFileStream = getDataFile("appengineWebXmlWithoutProjectId.txt");
76+
InputStream expectedFileStream = getDataFile("appengineWebXml.txt");
9077
compareFileContent(expectedFileStream, testFileStream);
9178
}
9279

plugins/com.google.cloud.tools.eclipse.util.test/testData/templates/appengine/appengineWebXmlWithoutProjectId.txt renamed to plugins/com.google.cloud.tools.eclipse.util.test/testData/templates/appengine/appengineWebXml.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
33
<application></application>
4-
<version>1</version>
4+
<version></version>
55

66
<threadsafe>true</threadsafe>
77
<sessions-enabled>false</sessions-enabled>

plugins/com.google.cloud.tools.eclipse.util.test/testData/templates/appengine/appengineWebXmlWithProjectId.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

plugins/com.google.cloud.tools.eclipse.util/templates/appengine/appengine-web.xml.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
3-
<application>${projectId! ""}</application>
4-
<version>1</version>
3+
<application></application>
4+
<version></version>
55

66
<threadsafe>true</threadsafe>
77
<sessions-enabled>false</sessions-enabled>

0 commit comments

Comments
 (0)