Committed by
GauravAgrawal-Huawei
[ONOS-4711] Removed cyclic dependencies
because of JUNIT testcases Change-Id: I0402d224cbb0d0d541a1f47333a4e5de5cf240b0 (cherry picked from commit c5f63278)
Showing
14 changed files
with
91 additions
and
115 deletions
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.plugin.manager; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | 20 | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.plugin.manager; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | 20 | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.linker; | 17 | +package org.onosproject.yangutils.plugin.manager; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.Iterator; | 20 | import java.util.Iterator; |
| ... | @@ -33,8 +33,6 @@ import org.onosproject.yangutils.datamodel.YangUses; | ... | @@ -33,8 +33,6 @@ import org.onosproject.yangutils.datamodel.YangUses; |
| 33 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; | 33 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; |
| 34 | import org.onosproject.yangutils.linker.impl.YangLinkerManager; | 34 | import org.onosproject.yangutils.linker.impl.YangLinkerManager; |
| 35 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 35 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
| 36 | -import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | ||
| 37 | -import org.onosproject.yangutils.plugin.manager.YangUtilManager; | ||
| 38 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | 36 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
| 39 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 37 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
| 40 | 38 | ||
| ... | @@ -52,7 +50,6 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirector | ... | @@ -52,7 +50,6 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirector |
| 52 | */ | 50 | */ |
| 53 | public class InterFileLinkingTest { | 51 | public class InterFileLinkingTest { |
| 54 | 52 | ||
| 55 | - private final YangUtilsParserManager manager = new YangUtilsParserManager(); | ||
| 56 | private final YangUtilManager utilManager = new YangUtilManager(); | 53 | private final YangUtilManager utilManager = new YangUtilManager(); |
| 57 | private final YangLinkerManager yangLinkerManager = new YangLinkerManager(); | 54 | private final YangLinkerManager yangLinkerManager = new YangLinkerManager(); |
| 58 | 55 | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.linker; | 17 | +package org.onosproject.yangutils.plugin.manager; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.ListIterator; | 20 | import java.util.ListIterator; | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.linker; | 17 | +package org.onosproject.yangutils.plugin.manager; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.util.List; | 20 | import java.util.List; | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.plugin.manager; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | 20 | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.linker; | 17 | +package org.onosproject.yangutils.plugin.manager; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.math.BigInteger; | 20 | import java.math.BigInteger; | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.plugin.manager; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | 20 | ... | ... |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.plugin.manager; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | 20 | ... | ... |
| 1 | +package org.onosproject.yangutils.plugin.manager; | ||
| 2 | + | ||
| 3 | +import java.io.File; | ||
| 4 | +import java.io.IOException; | ||
| 5 | +import org.apache.commons.io.FileUtils; | ||
| 6 | +import org.apache.maven.project.MavenProject; | ||
| 7 | +import org.junit.Test; | ||
| 8 | +import org.sonatype.plexus.build.incremental.BuildContext; | ||
| 9 | +import org.sonatype.plexus.build.incremental.DefaultBuildContext; | ||
| 10 | + | ||
| 11 | +import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Created by root1 on 16/6/16. | ||
| 15 | + */ | ||
| 16 | +public class YangPluginUtilsTest { | ||
| 17 | + | ||
| 18 | + private static final String BASE_DIR = "target/UnitTestCase"; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * This test case checks whether the source is getting added. | ||
| 22 | + */ | ||
| 23 | + @Test | ||
| 24 | + public void testForAddSource() throws IOException { | ||
| 25 | + | ||
| 26 | + MavenProject project = new MavenProject(); | ||
| 27 | + BuildContext context = new DefaultBuildContext(); | ||
| 28 | + File sourceDir = new File(BASE_DIR + File.separator + "yang"); | ||
| 29 | + sourceDir.mkdirs(); | ||
| 30 | + addToCompilationRoot(sourceDir.toString(), project, context); | ||
| 31 | + FileUtils.deleteDirectory(sourceDir); | ||
| 32 | + } | ||
| 33 | +} |
| ... | @@ -14,11 +14,10 @@ | ... | @@ -14,11 +14,10 @@ |
| 14 | * limitations under the License. | 14 | * limitations under the License. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | -package org.onosproject.yangutils.translator.tojava.utils; | 17 | +package org.onosproject.yangutils.translator.tojava.javamodel; |
| 18 | 18 | ||
| 19 | import java.lang.reflect.Constructor; | 19 | import java.lang.reflect.Constructor; |
| 20 | import java.lang.reflect.InvocationTargetException; | 20 | import java.lang.reflect.InvocationTargetException; |
| 21 | - | ||
| 22 | import org.junit.Test; | 21 | import org.junit.Test; |
| 23 | import org.onosproject.yangutils.datamodel.YangDataTypes; | 22 | import org.onosproject.yangutils.datamodel.YangDataTypes; |
| 24 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; | 23 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; |
| ... | @@ -26,9 +25,6 @@ import org.onosproject.yangutils.datamodel.YangNode; | ... | @@ -26,9 +25,6 @@ import org.onosproject.yangutils.datamodel.YangNode; |
| 26 | import org.onosproject.yangutils.datamodel.YangType; | 25 | import org.onosproject.yangutils.datamodel.YangType; |
| 27 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 26 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 28 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | 27 | import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
| 29 | -import org.onosproject.yangutils.translator.tojava.javamodel.AttributesJavaDataType; | ||
| 30 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | ||
| 31 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef; | ||
| 32 | import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; | 28 | import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; |
| 33 | 29 | ||
| 34 | import static org.hamcrest.core.Is.is; | 30 | import static org.hamcrest.core.Is.is; | ... | ... |
| ... | @@ -16,26 +16,30 @@ | ... | @@ -16,26 +16,30 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.yangutils.translator.tojava.utils; | 17 | package org.onosproject.yangutils.translator.tojava.utils; |
| 18 | 18 | ||
| 19 | +import java.io.File; | ||
| 20 | +import java.io.IOException; | ||
| 19 | import java.lang.reflect.Constructor; | 21 | import java.lang.reflect.Constructor; |
| 20 | import java.lang.reflect.InvocationTargetException; | 22 | import java.lang.reflect.InvocationTargetException; |
| 21 | - | ||
| 22 | import org.junit.Rule; | 23 | import org.junit.Rule; |
| 23 | import org.junit.Test; | 24 | import org.junit.Test; |
| 24 | import org.junit.rules.ExpectedException; | 25 | import org.junit.rules.ExpectedException; |
| 25 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 26 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
| 26 | import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; | 27 | import org.onosproject.yangutils.utils.io.impl.YangToJavaNamingConflictUtil; |
| 27 | 28 | ||
| 29 | +import static org.apache.commons.io.FileUtils.deleteDirectory; | ||
| 28 | import static org.hamcrest.core.Is.is; | 30 | import static org.hamcrest.core.Is.is; |
| 29 | import static org.hamcrest.core.IsNot.not; | 31 | import static org.hamcrest.core.IsNot.not; |
| 30 | import static org.junit.Assert.assertThat; | 32 | import static org.junit.Assert.assertThat; |
| 33 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.doesPackageExist; | ||
| 34 | +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | ||
| 35 | +import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG; | ||
| 36 | +import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | ||
| 37 | +import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | ||
| 31 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; | 38 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; |
| 32 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; | 39 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; |
| 33 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; | 40 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getJavaPackageFromPackagePath; |
| 34 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; | 41 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage; |
| 35 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; | ||
| 36 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; | 42 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase; |
| 37 | -import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT_BASE_PKG; | ||
| 38 | -import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | ||
| 39 | 43 | ||
| 40 | /** | 44 | /** |
| 41 | * Unit tests for java identifier syntax. | 45 | * Unit tests for java identifier syntax. |
| ... | @@ -101,25 +105,30 @@ public final class JavaIdentifierSyntaxTest { | ... | @@ -101,25 +105,30 @@ public final class JavaIdentifierSyntaxTest { |
| 101 | private static final String WITH_CAMEL_CASE_WITH_PREFIX = "123addPrefixTry"; | 105 | private static final String WITH_CAMEL_CASE_WITH_PREFIX = "123addPrefixTry"; |
| 102 | private static final String WITH_CAMEL_CASE_WITH_PREFIX1 = "abc1234567890Ss1123G123Gaa"; | 106 | private static final String WITH_CAMEL_CASE_WITH_PREFIX1 = "abc1234567890Ss1123G123Gaa"; |
| 103 | private static YangToJavaNamingConflictUtil conflictResolver = new YangToJavaNamingConflictUtil(); | 107 | private static YangToJavaNamingConflictUtil conflictResolver = new YangToJavaNamingConflictUtil(); |
| 108 | + private static final String BASE_DIR_PKG = "target.UnitTestCase."; | ||
| 109 | + private static final String DIR_PATH = "exist1.exist2.exist3"; | ||
| 110 | + private static final String PKG_INFO = "package-info.java"; | ||
| 111 | + private static final String BASE_PKG = "target/UnitTestCase"; | ||
| 112 | + private static final String TEST_DATA_1 = "This is to append a text to the file first1\n"; | ||
| 104 | 113 | ||
| 105 | /** | 114 | /** |
| 106 | * Unit test for private constructor. | 115 | * Unit test for private constructor. |
| 107 | * | 116 | * |
| 108 | - * @throws SecurityException if any security violation is observed. | 117 | + * @throws SecurityException if any security violation is observed. |
| 109 | - * @throws NoSuchMethodException if when the method is not found. | 118 | + * @throws NoSuchMethodException if when the method is not found. |
| 110 | - * @throws IllegalArgumentException if there is illegal argument found. | 119 | + * @throws IllegalArgumentException if there is illegal argument found. |
| 111 | - * @throws InstantiationException if instantiation is provoked for the | 120 | + * @throws InstantiationException if instantiation is provoked for the |
| 112 | - * private constructor. | 121 | + * private constructor. |
| 113 | - * @throws IllegalAccessException if instance is provoked or a method is | 122 | + * @throws IllegalAccessException if instance is provoked or a method is |
| 114 | - * provoked. | 123 | + * provoked. |
| 115 | * @throws InvocationTargetException when an exception occurs by the method | 124 | * @throws InvocationTargetException when an exception occurs by the method |
| 116 | - * or constructor. | 125 | + * or constructor. |
| 117 | */ | 126 | */ |
| 118 | @Test | 127 | @Test |
| 119 | public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException, | 128 | public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException, |
| 120 | InstantiationException, IllegalAccessException, InvocationTargetException { | 129 | InstantiationException, IllegalAccessException, InvocationTargetException { |
| 121 | 130 | ||
| 122 | - Class<?>[] classesToConstruct = {JavaIdentifierSyntax.class }; | 131 | + Class<?>[] classesToConstruct = {JavaIdentifierSyntax.class}; |
| 123 | for (Class<?> clazz : classesToConstruct) { | 132 | for (Class<?> clazz : classesToConstruct) { |
| 124 | Constructor<?> constructor = clazz.getDeclaredConstructor(); | 133 | Constructor<?> constructor = clazz.getDeclaredConstructor(); |
| 125 | constructor.setAccessible(true); | 134 | constructor.setAccessible(true); |
| ... | @@ -282,4 +291,23 @@ public final class JavaIdentifierSyntaxTest { | ... | @@ -282,4 +291,23 @@ public final class JavaIdentifierSyntaxTest { |
| 282 | String path = getPackageDirPathFromJavaJPackage(PARENT_WITH_PERIOD); | 291 | String path = getPackageDirPathFromJavaJPackage(PARENT_WITH_PERIOD); |
| 283 | assertThat(path.equals(PARENT_PACKAGE), is(true)); | 292 | assertThat(path.equals(PARENT_PACKAGE), is(true)); |
| 284 | } | 293 | } |
| 294 | + | ||
| 295 | + | ||
| 296 | + /** | ||
| 297 | + * This test case checks whether the package is existing. | ||
| 298 | + * | ||
| 299 | + * @throws IOException when failed to create a test file | ||
| 300 | + */ | ||
| 301 | + @Test | ||
| 302 | + public void packageExistTest() throws IOException { | ||
| 303 | + | ||
| 304 | + String strPath = BASE_DIR_PKG + DIR_PATH; | ||
| 305 | + File createDir = new File(strPath.replace(PERIOD, SLASH)); | ||
| 306 | + createDir.mkdirs(); | ||
| 307 | + File createFile = new File(createDir + SLASH + PKG_INFO); | ||
| 308 | + createFile.createNewFile(); | ||
| 309 | + assertThat(true, is(doesPackageExist(strPath))); | ||
| 310 | + createDir.delete(); | ||
| 311 | + deleteDirectory(createDir); | ||
| 312 | + } | ||
| 285 | } | 313 | } | ... | ... |
utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtilTest.java
| ... | @@ -20,21 +20,13 @@ import java.io.File; | ... | @@ -20,21 +20,13 @@ import java.io.File; |
| 20 | import java.io.IOException; | 20 | import java.io.IOException; |
| 21 | import java.lang.reflect.Constructor; | 21 | import java.lang.reflect.Constructor; |
| 22 | import java.lang.reflect.InvocationTargetException; | 22 | import java.lang.reflect.InvocationTargetException; |
| 23 | - | ||
| 24 | import org.junit.Test; | 23 | import org.junit.Test; |
| 25 | -import org.onosproject.yangutils.datamodel.YangNode; | ||
| 26 | -import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ||
| 27 | -import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule; | ||
| 28 | 24 | ||
| 29 | import static org.apache.commons.io.FileUtils.deleteDirectory; | 25 | import static org.apache.commons.io.FileUtils.deleteDirectory; |
| 30 | -import static org.hamcrest.core.Is.is; | ||
| 31 | import static org.hamcrest.core.IsNot.not; | 26 | import static org.hamcrest.core.IsNot.not; |
| 32 | import static org.junit.Assert.assertThat; | 27 | import static org.junit.Assert.assertThat; |
| 33 | -import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; | ||
| 34 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; | 28 | import static org.onosproject.yangutils.utils.UtilConstants.SLASH; |
| 35 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents; | 29 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.appendFileContents; |
| 36 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; | ||
| 37 | -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.doesPackageExist; | ||
| 38 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; | 30 | import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileHandle; |
| 39 | 31 | ||
| 40 | /** | 32 | /** |
| ... | @@ -42,24 +34,21 @@ import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileH | ... | @@ -42,24 +34,21 @@ import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.updateFileH |
| 42 | */ | 34 | */ |
| 43 | public final class FileSystemUtilTest { | 35 | public final class FileSystemUtilTest { |
| 44 | 36 | ||
| 45 | - private static final String BASE_DIR_PKG = "target.UnitTestCase."; | ||
| 46 | private static final String BASE_PKG = "target/UnitTestCase"; | 37 | private static final String BASE_PKG = "target/UnitTestCase"; |
| 47 | private static final String TEST_DATA_1 = "This is to append a text to the file first1\n"; | 38 | private static final String TEST_DATA_1 = "This is to append a text to the file first1\n"; |
| 48 | private static final String TEST_DATA_2 = "This is next second line\n"; | 39 | private static final String TEST_DATA_2 = "This is next second line\n"; |
| 49 | private static final String TEST_DATA_3 = "This is next third line in the file"; | 40 | private static final String TEST_DATA_3 = "This is next third line in the file"; |
| 50 | private static final String TEST_FILE = "testFile"; | 41 | private static final String TEST_FILE = "testFile"; |
| 51 | private static final String SOURCE_TEST_FILE = "sourceTestFile"; | 42 | private static final String SOURCE_TEST_FILE = "sourceTestFile"; |
| 52 | - private static final String DIR_PATH = "exist1.exist2.exist3"; | ||
| 53 | - private static final String PKG_INFO = "package-info.java"; | ||
| 54 | 43 | ||
| 55 | /** | 44 | /** |
| 56 | * A private constructor is tested. | 45 | * A private constructor is tested. |
| 57 | * | 46 | * |
| 58 | - * @throws SecurityException if any security violation is observed | 47 | + * @throws SecurityException if any security violation is observed |
| 59 | - * @throws NoSuchMethodException if when the method is not found | 48 | + * @throws NoSuchMethodException if when the method is not found |
| 60 | - * @throws IllegalArgumentException if there is illegal argument found | 49 | + * @throws IllegalArgumentException if there is illegal argument found |
| 61 | - * @throws InstantiationException if instantiation is provoked for the private constructor | 50 | + * @throws InstantiationException if instantiation is provoked for the private constructor |
| 62 | - * @throws IllegalAccessException if instance is provoked or a method is provoked | 51 | + * @throws IllegalAccessException if instance is provoked or a method is provoked |
| 63 | * @throws InvocationTargetException when an exception occurs by the method or constructor | 52 | * @throws InvocationTargetException when an exception occurs by the method or constructor |
| 64 | */ | 53 | */ |
| 65 | @Test | 54 | @Test |
| ... | @@ -67,7 +56,7 @@ public final class FileSystemUtilTest { | ... | @@ -67,7 +56,7 @@ public final class FileSystemUtilTest { |
| 67 | throws SecurityException, NoSuchMethodException, IllegalArgumentException, | 56 | throws SecurityException, NoSuchMethodException, IllegalArgumentException, |
| 68 | InstantiationException, IllegalAccessException, InvocationTargetException { | 57 | InstantiationException, IllegalAccessException, InvocationTargetException { |
| 69 | 58 | ||
| 70 | - Class<?>[] classesToConstruct = {FileSystemUtil.class }; | 59 | + Class<?>[] classesToConstruct = {FileSystemUtil.class}; |
| 71 | for (Class<?> clazz : classesToConstruct) { | 60 | for (Class<?> clazz : classesToConstruct) { |
| 72 | Constructor<?> constructor = clazz.getDeclaredConstructor(); | 61 | Constructor<?> constructor = clazz.getDeclaredConstructor(); |
| 73 | constructor.setAccessible(true); | 62 | constructor.setAccessible(true); |
| ... | @@ -96,52 +85,4 @@ public final class FileSystemUtilTest { | ... | @@ -96,52 +85,4 @@ public final class FileSystemUtilTest { |
| 96 | updateFileHandle(createFile, null, true); | 85 | updateFileHandle(createFile, null, true); |
| 97 | deleteDirectory(dir); | 86 | deleteDirectory(dir); |
| 98 | } | 87 | } |
| 99 | - | ||
| 100 | - /** | ||
| 101 | - * This test case checks whether the package is existing. | ||
| 102 | - * | ||
| 103 | - * @throws IOException when failed to create a test file | ||
| 104 | - */ | ||
| 105 | - @Test | ||
| 106 | - public void packageExistTest() throws IOException { | ||
| 107 | - | ||
| 108 | - String strPath = BASE_DIR_PKG + DIR_PATH; | ||
| 109 | - File createDir = new File(strPath.replace(PERIOD, SLASH)); | ||
| 110 | - createDir.mkdirs(); | ||
| 111 | - File createFile = new File(createDir + SLASH + PKG_INFO); | ||
| 112 | - createFile.createNewFile(); | ||
| 113 | - assertThat(true, is(doesPackageExist(strPath))); | ||
| 114 | - createPackage(getStubNode()); | ||
| 115 | - createDir.delete(); | ||
| 116 | - deleteDirectory(createDir); | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - /** | ||
| 120 | - * Returns stub YANG node. | ||
| 121 | - * | ||
| 122 | - * @return stub node | ||
| 123 | - */ | ||
| 124 | - private YangNode getStubNode() { | ||
| 125 | - YangJavaModule module = new YangJavaModule(); | ||
| 126 | - module.setName(TEST_DATA_1); | ||
| 127 | - JavaFileInfo javafileInfo = new JavaFileInfo(); | ||
| 128 | - javafileInfo.setJavaName(TEST_DATA_1); | ||
| 129 | - javafileInfo.setBaseCodeGenPath(""); | ||
| 130 | - javafileInfo.setPackageFilePath(BASE_PKG); | ||
| 131 | - javafileInfo.setPluginConfig(getStubPluginConfig()); | ||
| 132 | - module.setJavaFileInfo(javafileInfo); | ||
| 133 | - return module; | ||
| 134 | - } | ||
| 135 | - | ||
| 136 | - /** | ||
| 137 | - * Returns stub pluginConfig. | ||
| 138 | - * | ||
| 139 | - * @return stub pluginConfig | ||
| 140 | - */ | ||
| 141 | - private YangPluginConfig getStubPluginConfig() { | ||
| 142 | - YangPluginConfig pluginConfig = new YangPluginConfig(); | ||
| 143 | - pluginConfig.setConflictResolver(null); | ||
| 144 | - return pluginConfig; | ||
| 145 | - } | ||
| 146 | - | ||
| 147 | } | 88 | } | ... | ... |
| ... | @@ -20,23 +20,18 @@ import java.io.File; | ... | @@ -20,23 +20,18 @@ import java.io.File; |
| 20 | import java.io.IOException; | 20 | import java.io.IOException; |
| 21 | import java.lang.reflect.Constructor; | 21 | import java.lang.reflect.Constructor; |
| 22 | import java.lang.reflect.InvocationTargetException; | 22 | import java.lang.reflect.InvocationTargetException; |
| 23 | - | ||
| 24 | import org.apache.commons.io.FileUtils; | 23 | import org.apache.commons.io.FileUtils; |
| 25 | -import org.apache.maven.project.MavenProject; | ||
| 26 | import org.junit.Rule; | 24 | import org.junit.Rule; |
| 27 | import org.junit.Test; | 25 | import org.junit.Test; |
| 28 | import org.junit.rules.ExpectedException; | 26 | import org.junit.rules.ExpectedException; |
| 29 | import org.onosproject.yangutils.utils.UtilConstants; | 27 | import org.onosproject.yangutils.utils.UtilConstants; |
| 30 | -import org.sonatype.plexus.build.incremental.BuildContext; | ||
| 31 | -import org.sonatype.plexus.build.incremental.DefaultBuildContext; | ||
| 32 | 28 | ||
| 33 | import static org.hamcrest.core.Is.is; | 29 | import static org.hamcrest.core.Is.is; |
| 34 | import static org.hamcrest.core.IsNot.not; | 30 | import static org.hamcrest.core.IsNot.not; |
| 35 | import static org.junit.Assert.assertThat; | 31 | import static org.junit.Assert.assertThat; |
| 36 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo; | 32 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.addPackageInfo; |
| 37 | -import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; | ||
| 38 | -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ||
| 39 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories; | 33 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.createDirectories; |
| 34 | +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory; | ||
| 40 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; | 35 | import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; |
| 41 | 36 | ||
| 42 | /** | 37 | /** |
| ... | @@ -189,20 +184,6 @@ public final class YangIoUtilsTest { | ... | @@ -189,20 +184,6 @@ public final class YangIoUtilsTest { |
| 189 | } | 184 | } |
| 190 | 185 | ||
| 191 | /** | 186 | /** |
| 192 | - * This test case checks whether the source is getting added. | ||
| 193 | - */ | ||
| 194 | - @Test | ||
| 195 | - public void testForAddSource() throws IOException { | ||
| 196 | - | ||
| 197 | - MavenProject project = new MavenProject(); | ||
| 198 | - BuildContext context = new DefaultBuildContext(); | ||
| 199 | - File sourceDir = new File(BASE_DIR + File.separator + "yang"); | ||
| 200 | - sourceDir.mkdirs(); | ||
| 201 | - addToCompilationRoot(sourceDir.toString(), project, context); | ||
| 202 | - FileUtils.deleteDirectory(sourceDir); | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - /** | ||
| 206 | * Unit test case for trim at last method. | 187 | * Unit test case for trim at last method. |
| 207 | */ | 188 | */ |
| 208 | @Test | 189 | @Test | ... | ... |
-
Please register or login to post a comment