aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache')
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java76
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java136
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java93
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java45
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java79
-rw-r--r--framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java87
6 files changed, 516 insertions, 0 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java
new file mode 100644
index 00000000..bf0f8477
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemCollectorTest.java
@@ -0,0 +1,76 @@
+package org.apache.maven.building;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.*;
+
+import org.apache.maven.building.Problem.Severity;
+import org.junit.Test;
+
+public class DefaultProblemCollectorTest
+{
+
+ @Test
+ public void testGetProblems()
+ {
+ DefaultProblemCollector collector = new DefaultProblemCollector( null );
+ assertNotNull( collector.getProblems() );
+ assertEquals( 0, collector.getProblems().size() );
+
+ collector.add( null, "MESSAGE1", -1, -1, null );
+
+ Exception e2 = new Exception();
+ collector.add( Severity.WARNING, null, 42, 127, e2 );
+
+ assertEquals( 2, collector.getProblems().size() );
+
+ Problem p1 = collector.getProblems().get(0);
+ assertEquals( Severity.ERROR, p1.getSeverity() );
+ assertEquals( "MESSAGE1",p1.getMessage() );
+ assertEquals( -1, p1.getLineNumber() );
+ assertEquals( -1, p1.getColumnNumber() );
+ assertEquals( null, p1.getException() );
+
+ Problem p2 = collector.getProblems().get(1);
+ assertEquals( Severity.WARNING, p2.getSeverity() );
+ assertEquals( "",p2.getMessage() );
+ assertEquals( 42, p2.getLineNumber() );
+ assertEquals( 127, p2.getColumnNumber() );
+ assertEquals( e2, p2.getException() );
+ }
+
+ @Test
+ public void testSetSource()
+ {
+ DefaultProblemCollector collector = new DefaultProblemCollector( null );
+
+ collector.add( null, "PROBLEM1", -1, -1, null );
+
+ collector.setSource( "SOURCE_PROBLEM2" );
+ collector.add( null, "PROBLEM2", -1, -1, null );
+
+ collector.setSource( "SOURCE_PROBLEM3" );
+ collector.add( null, "PROBLEM3", -1, -1, null );
+
+ assertEquals( "", collector.getProblems().get( 0 ).getSource() );
+ assertEquals( "SOURCE_PROBLEM2", collector.getProblems().get( 1 ).getSource() );
+ assertEquals( "SOURCE_PROBLEM3", collector.getProblems().get( 2 ).getSource() );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java
new file mode 100644
index 00000000..80a20da9
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/DefaultProblemTest.java
@@ -0,0 +1,136 @@
+package org.apache.maven.building;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import org.apache.maven.building.Problem.Severity;
+import org.junit.Test;
+
+public class DefaultProblemTest
+{
+
+ @Test
+ public void testGetSeverity()
+ {
+ DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null );
+ assertEquals( Severity.ERROR, problem.getSeverity() );
+
+ problem = new DefaultProblem( null, Severity.FATAL, null, -1, -1, null );
+ assertEquals( Severity.FATAL, problem.getSeverity() );
+
+ problem = new DefaultProblem( null, Severity.ERROR, null, -1, -1, null );
+ assertEquals( Severity.ERROR, problem.getSeverity() );
+
+ problem = new DefaultProblem( null, Severity.WARNING, null, -1, -1, null );
+ assertEquals( Severity.WARNING, problem.getSeverity() );
+ }
+
+ @Test
+ public void testGetLineNumber()
+ {
+ DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null );
+ assertEquals( -1, problem.getLineNumber() );
+
+ problem = new DefaultProblem( null, null, null, 42, -1, null );
+ assertEquals( 42, problem.getLineNumber() );
+
+ problem = new DefaultProblem( null, null, null, Integer.MAX_VALUE, -1, null );
+ assertEquals( Integer.MAX_VALUE, problem.getLineNumber() );
+
+ // this case is not specified, might also return -1
+ problem = new DefaultProblem( null, null, null, Integer.MIN_VALUE, -1, null );
+ assertEquals( Integer.MIN_VALUE, problem.getLineNumber() );
+ }
+
+ @Test
+ public void testGetColumnNumber()
+ {
+ DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null );
+ assertEquals( -1, problem.getColumnNumber() );
+
+ problem = new DefaultProblem( null, null, null, -1, 42, null );
+ assertEquals( 42, problem.getColumnNumber() );
+
+ problem = new DefaultProblem( null, null, null, -1, Integer.MAX_VALUE, null );
+ assertEquals( Integer.MAX_VALUE, problem.getColumnNumber() );
+
+ // this case is not specified, might also return -1
+ problem = new DefaultProblem( null, null, null, -1, Integer.MIN_VALUE, null );
+ assertEquals( Integer.MIN_VALUE, problem.getColumnNumber() );
+ }
+
+ @Test
+ public void testGetException()
+ {
+ DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null );
+ assertEquals( null, problem.getException() );
+
+ Exception e = new Exception();
+ problem = new DefaultProblem( null, null, null, -1, -1, e );
+ assertSame( e, problem.getException() );
+ }
+
+ @Test
+ public void testGetSource()
+ {
+ DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null );
+ assertEquals( "", problem.getSource() );
+
+ problem = new DefaultProblem( null, null, "", -1, -1, null );
+ assertEquals( "", problem.getSource() );
+
+ problem = new DefaultProblem( null, null, "SOURCE", -1, -1, null );
+ assertEquals( "SOURCE", problem.getSource() );
+ }
+
+ @Test
+ public void testGetLocation()
+ {
+ DefaultProblem problem = new DefaultProblem( null, null, null, -1, -1, null );
+ assertEquals( "", problem.getLocation() );
+
+ problem = new DefaultProblem( null, null, "SOURCE", -1, -1, null );
+ assertEquals( "SOURCE", problem.getLocation() );
+
+ problem = new DefaultProblem( null, null, null, 42, -1, null );
+ assertEquals( "line 42", problem.getLocation() );
+
+ problem = new DefaultProblem( null, null, null, -1, 127, null );
+ assertEquals( "column 127", problem.getLocation() );
+
+ problem = new DefaultProblem( null, null, "SOURCE", 42, 127, null );
+ assertEquals( "SOURCE, line 42, column 127", problem.getLocation() );
+ }
+
+ @Test
+ public void testGetMessage()
+ {
+ DefaultProblem problem = new DefaultProblem( "MESSAGE", null, null, -1, -1, null );
+ assertEquals( "MESSAGE", problem.getMessage() );
+
+ problem = new DefaultProblem( null, null, null, -1, -1, new Exception() );
+ assertEquals( "", problem.getMessage() );
+
+ problem = new DefaultProblem( null, null, null, -1, -1, new Exception( "EXCEPTION MESSAGE" ) );
+ assertEquals( "EXCEPTION MESSAGE", problem.getMessage() );
+ }
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java
new file mode 100644
index 00000000..086adda8
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/FileSourceTest.java
@@ -0,0 +1,93 @@
+package org.apache.maven.building;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Scanner;
+
+import org.junit.Test;
+
+public class FileSourceTest
+{
+
+ @Test
+ public void testFileSource()
+ {
+ try
+ {
+ new FileSource( null );
+ fail( "Should fail, since you must specify a file" );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ assertEquals( "no file specified", e.getMessage() );
+ }
+ }
+
+ @Test
+ public void testGetInputStream()
+ throws Exception
+ {
+ File txtFile = new File( "target/test-classes/source.txt" );
+ FileSource source = new FileSource( txtFile );
+
+ Scanner scanner = null;
+ InputStream is = null;
+ try
+ {
+ is = source.getInputStream();
+
+ scanner = new Scanner( is );
+ assertEquals( "Hello World!", scanner.nextLine() );
+ }
+ finally
+ {
+ if ( scanner != null )
+ {
+ scanner.close();
+ }
+ if ( is != null )
+ {
+ is.close();
+ }
+ }
+ }
+
+ @Test
+ public void testGetLocation()
+ {
+ File txtFile = new File( "target/test-classes/source.txt" );
+ FileSource source = new FileSource( txtFile );
+ assertEquals( txtFile.getAbsolutePath(), source.getLocation() );
+ }
+
+ @Test
+ public void testGetFile()
+ {
+ File txtFile = new File( "target/test-classes/source.txt" );
+ FileSource source = new FileSource( txtFile );
+ assertEquals( txtFile.getAbsoluteFile(), source.getFile() );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java
new file mode 100644
index 00000000..44c7906c
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/ProblemCollectorFactoryTest.java
@@ -0,0 +1,45 @@
+package org.apache.maven.building;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+import java.util.Collections;
+
+import org.junit.Test;
+
+public class ProblemCollectorFactoryTest
+{
+
+ @Test
+ public void testNewInstance()
+ {
+ ProblemCollector collector1 = ProblemCollectorFactory.newInstance( null );
+
+ Problem problem = new DefaultProblem( "MESSAGE1", null, null, -1, -1, null );
+ ProblemCollector collector2 = ProblemCollectorFactory.newInstance( Collections.singletonList( problem ) );
+
+ assertNotSame( collector1, collector2 );
+ assertEquals( 0, collector1.getProblems().size() );
+ assertEquals( 1, collector2.getProblems().size() );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java
new file mode 100644
index 00000000..013b8a4d
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/StringSourceTest.java
@@ -0,0 +1,79 @@
+package org.apache.maven.building;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.Scanner;
+
+import org.junit.Test;
+
+public class StringSourceTest
+{
+ @Test
+ public void testGetInputStream()
+ throws Exception
+ {
+ StringSource source = new StringSource( "Hello World!" );
+
+ Scanner scanner = null;
+ InputStream is = null;
+ try
+ {
+ is = source.getInputStream();
+
+ scanner = new Scanner( is );
+ assertEquals( "Hello World!", scanner.nextLine() );
+ }
+ finally
+ {
+ if ( scanner != null )
+ {
+ scanner.close();
+ }
+ if ( is != null )
+ {
+ is.close();
+ }
+ }
+ }
+
+ @Test
+ public void testGetLocation()
+ {
+ StringSource source = new StringSource( "Hello World!" );
+ assertEquals( "(memory)", source.getLocation() );
+
+ source = new StringSource( "Hello World!", "LOCATION" );
+ assertEquals( "LOCATION", source.getLocation() );
+ }
+
+ @Test
+ public void testGetContent()
+ {
+ StringSource source = new StringSource( null );
+ assertEquals( "", source.getContent() );
+
+ source = new StringSource( "Hello World!", "LOCATION" );
+ assertEquals( "Hello World!", source.getContent() );
+ }
+
+}
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java
new file mode 100644
index 00000000..5524c9b3
--- /dev/null
+++ b/framework/src/maven/apache-maven-3.3.3/maven-builder-support/src/test/java/org/apache/maven/building/UrlSourceTest.java
@@ -0,0 +1,87 @@
+package org.apache.maven.building;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Scanner;
+
+import org.junit.Test;
+
+public class UrlSourceTest
+{
+
+ @Test
+ public void testUrlSource()
+ {
+ try
+ {
+ new UrlSource( null );
+ fail( "Should fail, since you must specify a url" );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ assertEquals( "no url specified", e.getMessage() );
+ }
+ }
+
+ @Test
+ public void testGetInputStream()
+ throws Exception
+ {
+ URL txtFile = new File( "target/test-classes/source.txt" ).toURI().toURL();
+ UrlSource source = new UrlSource( txtFile );
+
+ Scanner scanner = null;
+ InputStream is = null;
+ try
+ {
+ is = source.getInputStream();
+
+ scanner = new Scanner( is );
+ assertEquals( "Hello World!", scanner.nextLine() );
+ }
+ finally
+ {
+ if ( scanner != null )
+ {
+ scanner.close();
+ }
+ if ( is != null )
+ {
+ is.close();
+ }
+ }
+ }
+
+ @Test
+ public void testGetLocation()
+ throws Exception
+ {
+ URL txtFile = new File( "target/test-classes/source.txt" ).toURI().toURL();
+ UrlSource source = new UrlSource( txtFile );
+ assertEquals( txtFile.toExternalForm(), source.getLocation() );
+ }
+
+}