-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better indentation when adding GCP libraries to pom.xml #3511
Open
lak-proddev
wants to merge
6
commits into
GoogleCloudPlatform:master
Choose a base branch
from
lak-proddev:#3381
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5d028af
Better indentation when adding GCP libraries to pom.xml #3381
lak-proddev 5f56823
#3381 - test case added
lak-proddev 8194366
#3381 - test case updated
lak-proddev 45c771d
#3381 - test case updated
lak-proddev 38d59ea
#3381 - test case updated
lak-proddev 741ded9
Typo
lak-proddev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -16,15 +16,13 @@ | |
|
||
package com.google.cloud.tools.eclipse.appengine.libraries; | ||
|
||
import static org.junit.Assert.fail; | ||
import static org.junit.Assert.assertArrayEquals; | ||
|
||
import com.google.cloud.tools.eclipse.appengine.libraries.model.Library; | ||
import com.google.cloud.tools.eclipse.appengine.libraries.model.LibraryFile; | ||
import com.google.cloud.tools.eclipse.test.util.project.TestProjectCreator; | ||
import com.google.cloud.tools.eclipse.util.ArtifactRetriever; | ||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
|
@@ -39,13 +37,14 @@ | |
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.FileLocator; | ||
import org.eclipse.core.runtime.Platform; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.osgi.framework.Bundle; | ||
import org.xml.sax.SAXException; | ||
|
||
public class POMFormatTest { | ||
public class PomFormatTest { | ||
|
||
@Rule | ||
public final TestProjectCreator projectCreator = new TestProjectCreator(); | ||
|
@@ -66,6 +65,11 @@ public void setUp() throws SAXException, IOException, CoreException { | |
logger.setLevel(Level.OFF); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
Logger logger = Logger.getLogger(ArtifactRetriever.class.getName()); | ||
logger.setLevel(null); | ||
} | ||
|
||
@Test | ||
public void testAddDependencies() throws Exception { | ||
|
@@ -81,8 +85,8 @@ public void testAddDependencies() throws Exception { | |
pom.addDependencies(libraries); | ||
|
||
Bundle bundle = Platform.getBundle("com.google.cloud.tools.eclipse.appengine.libraries.test"); | ||
URL fileURL = bundle.getEntry("/testdata/formatAdd.xml"); | ||
File expected = new File(FileLocator.resolve(fileURL).toURI()); | ||
URL fileUrl = bundle.getEntry("/testdata/formatAdd.xml"); | ||
File expected = new File(FileLocator.resolve(fileUrl).toURI()); | ||
assertFileContentsEqual(pomFile.getLocation().toFile(), expected); | ||
|
||
} | ||
|
@@ -97,38 +101,12 @@ public void testRemoveUnusedDependencies() throws Exception { | |
pom.addDependencies(Arrays.asList(library1, library2)); | ||
|
||
Bundle bundle = Platform.getBundle("com.google.cloud.tools.eclipse.appengine.libraries.test"); | ||
URL fileURL = bundle.getEntry("/testdata/formatRemove.xml"); | ||
File expected = new File(FileLocator.resolve(fileURL).toURI()); | ||
URL fileUrl = bundle.getEntry("/testdata/formatRemove.xml"); | ||
File expected = new File(FileLocator.resolve(fileUrl).toURI()); | ||
assertFileContentsEqual(pomFile.getLocation().toFile(), expected); | ||
} | ||
|
||
public static void assertFileContentsEqual(File actual, File expected) throws IOException { | ||
boolean areEqual = true; | ||
try (BufferedReader reader1 = new BufferedReader(new FileReader(actual)); | ||
BufferedReader reader2 = new BufferedReader(new FileReader(expected));) { | ||
String line1 = reader1.readLine(); | ||
String line2 = reader2.readLine(); | ||
|
||
int lineNum = 1; | ||
|
||
while (line1 != null || line2 != null) { | ||
if (line1 == null || line2 == null) { | ||
areEqual = false; | ||
break; | ||
} else if (!line1.equalsIgnoreCase(line2)) { | ||
areEqual = false; | ||
break; | ||
} | ||
line1 = reader1.readLine(); | ||
line2 = reader2.readLine(); | ||
lineNum++; | ||
} | ||
if (!areEqual) { | ||
String message = "Two files have different content. They differ at line " + lineNum + " \"" | ||
+ actual.getName() + "\" has " + line1 + " and \"" + expected.getName() + "\" has " | ||
+ line2 + " at line " + lineNum + "\n"; | ||
fail(message); | ||
} | ||
} | ||
private static void assertFileContentsEqual(File actual, File expected) throws IOException { | ||
assertArrayEquals(Files.readAllBytes(actual.toPath()), Files.readAllBytes(expected.toPath())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. swap arguments since expected customarily comes before actual |
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swap arguments since expected customarily comes before actual