This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from salesforce/59-negative-project-import-tests
Added negative project import tests
- Loading branch information
Showing
24 changed files
with
383 additions
and
46 deletions.
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
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
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
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
Empty file.
13 changes: 13 additions & 0 deletions
13
com.salesforce.b2eclipse.tests/projects/build-with-class/module1/java/src/example/BUILD
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,13 @@ | ||
load("@rules_java//java:defs.bzl", "java_binary") | ||
|
||
java_binary( | ||
name = "ProjectRunner", | ||
srcs = glob(["*.java"]), | ||
main_class = "com.example.ProjectRunner", | ||
deps = [":greeter"], | ||
) | ||
|
||
java_library( | ||
name = "greeter", | ||
srcs = ["Greeting.java"], | ||
) |
7 changes: 7 additions & 0 deletions
7
...lesforce.b2eclipse.tests/projects/build-with-class/module1/java/src/example/Greeting.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,7 @@ | ||
package com.example; | ||
|
||
public class Greeting { | ||
public static void sayHi() { | ||
System.out.println("Hi!"); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...rce.b2eclipse.tests/projects/build-with-class/module1/java/src/example/ProjectRunner.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,7 @@ | ||
package com.example; | ||
|
||
public class ProjectRunner { | ||
public static void main(String args[]) { | ||
Greeting.sayHi(); | ||
} | ||
} |
Empty file.
8 changes: 8 additions & 0 deletions
8
com.salesforce.b2eclipse.tests/projects/build-with-subpackage/module/BUILD
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,8 @@ | ||
load("@rules_java//java:defs.bzl", "java_binary") | ||
|
||
java_binary( | ||
name = "ProjectRunner", | ||
srcs = glob(["java/src/example/ProjectRunner.java"]), | ||
main_class = "example.ProjectRunner", | ||
deps = ["//module/submodule:greeter"], | ||
) |
9 changes: 9 additions & 0 deletions
9
...b2eclipse.tests/projects/build-with-subpackage/module/java/src/example/ProjectRunner.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,9 @@ | ||
package example; | ||
|
||
import greeting.SayHi; | ||
|
||
public class ProjectRunner { | ||
public static void main(String args[]) { | ||
SayHi.sayHi(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
com.salesforce.b2eclipse.tests/projects/build-with-subpackage/module/submodule/BUILD
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,7 @@ | ||
load("@rules_java//java:defs.bzl", "java_library") | ||
|
||
java_library( | ||
name = "greeter", | ||
srcs = glob(["java/src/greeting/SayHi.java"]), | ||
visibility = ["//visibility:public"], | ||
) |
7 changes: 7 additions & 0 deletions
7
...clipse.tests/projects/build-with-subpackage/module/submodule/java/src/greeting/SayHi.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,7 @@ | ||
package greeting; | ||
|
||
public class SayHi { | ||
public static void sayHi() { | ||
System.out.println("Hi!"); | ||
} | ||
} |
Empty file.
Empty file.
13 changes: 13 additions & 0 deletions
13
com.salesforce.b2eclipse.tests/projects/build-with-workspace/module1/BUILD
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,13 @@ | ||
load("@rules_java//java:defs.bzl", "java_binary") | ||
|
||
java_binary( | ||
name = "ProjectRunner", | ||
srcs = glob(["src/main/java/com/example/ProjectRunner.java"]), | ||
main_class = "com.example.ProjectRunner", | ||
deps = [":greeter"], | ||
) | ||
|
||
java_library( | ||
name = "greeter", | ||
srcs = ["src/main/java/com/example/Greeting.java"], | ||
) |
7 changes: 7 additions & 0 deletions
7
...orce.b2eclipse.tests/projects/build-with-workspace/module1/java/src/example/Greeting.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,7 @@ | ||
package com.example; | ||
|
||
public class Greeting { | ||
public static void sayHi() { | ||
System.out.println("Hi!"); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...b2eclipse.tests/projects/build-with-workspace/module1/java/src/example/ProjectRunner.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,7 @@ | ||
package com.example; | ||
|
||
public class ProjectRunner { | ||
public static void main(String args[]) { | ||
Greeting.sayHi(); | ||
} | ||
} |
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
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
71 changes: 71 additions & 0 deletions
71
...orce.b2eclipse.tests/src/main/java/com/salesforce/b2eclipse/importer/BazelImportTest.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,71 @@ | ||
/** | ||
* Copyright (c) 2020, Salesforce.com, Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
* following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following | ||
* disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the | ||
* following disclaimer in the documentation and/or other materials provided with the distribution. | ||
* | ||
* 3. Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products | ||
* derived from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
*/ | ||
|
||
package com.salesforce.b2eclipse.importer; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test class for importing a general Bazel test project. | ||
*/ | ||
public class BazelImportTest extends BaseBazelImproterTest { | ||
|
||
public BazelImportTest() { | ||
super.setWorkspaceRootPackage(getScanner().getProjects("projects/bazel-ls-demo-project")); | ||
} | ||
|
||
@Before | ||
public void setup() { | ||
setSettings(BAZEL_SRC_PATH_VALUE); | ||
importProject(); | ||
} | ||
|
||
@Test | ||
public void testImport() throws CoreException { | ||
IProject module1Proj = getWorkspaceRoot().getProject("module1"); | ||
IProject module2Proj = getWorkspaceRoot().getProject("module2"); | ||
IProject module3Proj = getWorkspaceRoot().getProject("module3"); | ||
|
||
IProject[] referencedProjects = module1Proj.getReferencedProjects(); | ||
|
||
assertEquals(2, referencedProjects.length); | ||
|
||
assertTrue("Didn't find module2 in the referenced projects list", | ||
Arrays.stream(referencedProjects).anyMatch(proj -> proj.equals(module2Proj))); | ||
|
||
assertTrue("Didn't find module3 in the referenced projects list", | ||
Arrays.stream(referencedProjects).anyMatch(proj -> proj.equals(module3Proj))); | ||
} | ||
} |
Oops, something went wrong.