Issue #23507 deployment-common uses junit5 instead of junit4
diff --git a/nucleus/deployment/common/pom.xml b/nucleus/deployment/common/pom.xml
index ee7c7e7..db03842 100755
--- a/nucleus/deployment/common/pom.xml
+++ b/nucleus/deployment/common/pom.xml
@@ -101,6 +101,10 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
</dependency>
diff --git a/nucleus/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java b/nucleus/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java
index d34d5a5..0fa53a8 100644
--- a/nucleus/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java
+++ b/nucleus/deployment/common/src/test/java/com/sun/enterprise/deploy/shared/FileArchiveTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,64 +17,64 @@
package com.sun.enterprise.deploy.shared;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
import org.glassfish.api.deployment.archive.ReadableArchive;
import org.glassfish.api.deployment.archive.WritableArchive;
import org.glassfish.hk2.api.ServiceLocator;
-
-import java.io.OutputStream;
-import java.io.InputStream;
-import java.util.Vector;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-import java.util.logging.Handler;
-import java.util.logging.MemoryHandler;
-import com.sun.enterprise.util.OS;
-import java.util.Enumeration;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import java.io.File;
-import java.io.IOException;
import org.glassfish.tests.utils.Utils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.emptyIterable;
+import static org.hamcrest.Matchers.not;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
- *
* @author Tim Quinn
*/
public class FileArchiveTest {
public static final Logger deplLogger = org.glassfish.deployment.common.DeploymentContextImpl.deplLogger;
- private final static String LINE_SEP = System.getProperty("line.separator");
- private final static String STALE_ENTRY = "oldLower/oldFile.txt";
- private final static String SUBARCHIVE_NAME = "subarch";
+ private static final String EXPECTED_LOG_KEY = "NCLS-DEPLOYMENT-00022";
+ private static final String LINE_SEP = System.getProperty("line.separator");
+ private static final String STALE_ENTRY = "oldLower/oldFile.txt";
+ private static final String SUBARCHIVE_NAME = "subarch";
private File archiveDir;
private final Set<String> usualEntryNames =
- new HashSet<String>(Arrays.asList(new String[] {"sample.txt", "lower/other.txt"}));
+ new HashSet<>(Arrays.asList(new String[] {"sample.txt", "lower/other.txt"}));
private final Set<String> usualExpectedEntryNames = initUsualExpectedEntryNames();
private final Set<String> usualExpectedEntryNamesWithOverwrittenStaleEntry =
initUsualExpectedEntryNamesWithOverwrittenStaleEntry();
private final Set<String> usualSubarchiveEntryNames =
- new HashSet<String>(Arrays.asList(new String[] {"a.txt", "under/b.txt"}));
+ new HashSet<>(Arrays.asList(new String[] {"a.txt", "under/b.txt"}));
private final Set<String> usualExpectedSubarchiveEntryNames = initUsualExpectedSubarchiveEntryNames();
private Set<String> initUsualExpectedEntryNames() {
- final Set<String> expectedEntryNames = new HashSet<String>(usualEntryNames);
+ final Set<String> expectedEntryNames = new HashSet<>(usualEntryNames);
expectedEntryNames.add("lower");
return expectedEntryNames;
}
@@ -86,40 +87,30 @@
}
private Set<String> initUsualExpectedSubarchiveEntryNames() {
- final Set<String> result = new HashSet<String>(usualSubarchiveEntryNames);
+ final Set<String> result = new HashSet<>(usualSubarchiveEntryNames);
result.add("under");
return result;
}
- private static ServiceLocator habitat;
+ private static ServiceLocator locator;
private static ArchiveFactory archiveFactory;
+ private static RecordingHandler handler;
- private static RecordingHandler handler;
- private static MemoryHandler memoryHandler;
-
- public FileArchiveTest() {
- }
-
- @BeforeClass
+ @BeforeAll
public static void setUpClass() throws Exception {
- habitat = Utils.getNewHabitat();
- archiveFactory = habitat.getService(ArchiveFactory.class);
+ locator = Utils.getNewHabitat();
+ archiveFactory = locator.getService(ArchiveFactory.class);
handler = new RecordingHandler();
- memoryHandler = new MemoryHandler(handler, 10, Level.ALL);
deplLogger.addHandler(handler);
}
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
+ @BeforeEach
public void setUp() throws IOException {
archiveDir = tempDir();
}
- @After
+ @AfterEach
public void tearDown() {
if (archiveDir != null) {
clean(archiveDir);
@@ -145,26 +136,20 @@
}
if ( ! dir.delete()) {
dir.deleteOnExit();
- };
+ }
}
- private ReadableArchive createAndPopulateArchive(
- final Set<String> entryNames) throws Exception {
-
+ private ReadableArchive createAndPopulateArchive(final Set<String> entryNames) throws Exception {
WritableArchive instance = archiveFactory.createArchive(archiveDir.toURI()); //new FileArchive();
instance.create(archiveDir.toURI());
- /*
- * Add some entries.
- */
+ // Add some entries.
for (String entryName : entryNames) {
instance.putNextEntry(entryName);
instance.closeEntry();
}
-
instance.close();
-
return archiveFactory.openArchive(archiveDir);
}
@@ -183,40 +168,33 @@
return readableParent.getSubArchive(subarchiveName);
}
- private void createAndPopulateAndCheckArchive(
- final Set<String> entryNames) throws Exception {
+
+ private void createAndPopulateAndCheckArchive(final Set<String> entryNames) throws Exception {
final ReadableArchive instance = createAndPopulateArchive(entryNames);
checkArchive(instance, usualExpectedEntryNames);
}
- private void checkArchive(final ReadableArchive instance,
- final Set<String> expectedEntryNames) {
- final Set<String> foundEntryNames = new HashSet<String>();
-
- for (Enumeration<String> e = instance.entries(); e.hasMoreElements(); ) {
+ private void checkArchive(final ReadableArchive instance, final Set<String> expectedEntryNames) {
+ final Set<String> foundEntryNames = new HashSet<>();
+ for (Enumeration<String> e = instance.entries(); e.hasMoreElements();) {
foundEntryNames.add(e.nextElement());
}
-
- assertEquals("Missing or unexpected entry names reported", expectedEntryNames, foundEntryNames);
+ assertEquals(expectedEntryNames, foundEntryNames, "Missing or unexpected entry names reported");
}
- private void getListOfFiles(final FileArchive instance,
- final Set<String> expectedEntryNames,
- final Logger logger) {
- final List<String> foundEntryNames = new ArrayList<String>();
+ private void getListOfFiles(final FileArchive instance, final Set<String> expectedEntryNames, final Logger logger) {
+ final List<String> foundEntryNames = new ArrayList<>();
instance.getListOfFiles(archiveDir, foundEntryNames, null, logger);
-
- assertEquals("Missing or unexpected entry names reported", expectedEntryNames,
- new HashSet<String>(foundEntryNames));
+ assertEquals(expectedEntryNames, new HashSet<>(foundEntryNames), "Missing or unexpected entry names reported");
}
private void getListOfFilesCheckForLogRecord(FileArchive instance, final Set<String> expectedEntryNames) throws IOException {
handler.flush();
- getListOfFiles((FileArchive) instance, expectedEntryNames, deplLogger);
+ getListOfFiles(instance, expectedEntryNames, deplLogger);
if (handler.logRecords().size() != 1) {
final StringBuilder sb = new StringBuilder();
for (LogRecord record : handler.logRecords()) {
@@ -225,20 +203,16 @@
.append(record.getMessage())
.append(LINE_SEP);
}
- fail("Expected 1 log message but received " + handler.logRecords().size() + " as follows:" + LINE_SEP + sb.toString());
+ fail("Expected 1 log message but received " + handler.logRecords().size() + " as follows:" + LINE_SEP + sb);
}
- /*
- * We have a stale file under a stale directory. Make sure a direct
- * request for the stale file fails. (We know already from above that
- * getting the entries list triggers a warning about the skipped stale file.)
- */
+ // We have a stale file under a stale directory. Make sure a direct
+ // request for the stale file fails. (We know already from above that
+ // getting the entries list triggers a warning about the skipped stale file.)
final InputStream is = instance.getEntry(STALE_ENTRY);
- assertNull("Incorrectly located stale FileArchive entry " + STALE_ENTRY, is);
+ assertNull(is, "Incorrectly located stale FileArchive entry " + STALE_ENTRY);
}
-
-
/**
* Computes the expected entry names for an archive which contains a subarchive.
* <p>
@@ -250,7 +224,7 @@
* @return entry names that should be returned from the main archive's entries() method
*/
private Set<String> expectedEntryNames(Set<String> expectedFromArchive, final String subarchiveName, Set<String>expectedFromSubarchive) {
- final Set<String> result = new HashSet<String>(expectedFromArchive);
+ final Set<String> result = new HashSet<>(expectedFromArchive);
result.add(subarchiveName);
for (String expectedSubarchEntryName : expectedFromSubarchive) {
final StringBuilder path = new StringBuilder();
@@ -269,56 +243,42 @@
@Test
public void testSubarchive() throws Exception {
-
- System.out.println("testSubarchive");
final ArchiveAndSubarchive archives = createAndPopulateArchiveAndSubarchive();
-
-
- checkArchive((FileArchive) archives.parent, archives.fullExpectedEntryNames);
-
- checkArchive((FileArchive) archives.subarchive, usualExpectedSubarchiveEntryNames);
+ checkArchive(archives.parent, archives.fullExpectedEntryNames);
+ checkArchive(archives.subarchive, usualExpectedSubarchiveEntryNames);
}
@Test
public void testSubArchiveCreateWithStaleEntry() throws Exception {
System.out.println("testSubArchiveCreateWithStaleEntry");
- /*
- * Subarchives are a little tricky. The marker file lives only at
- * the top level (because that's where undeployment puts it). So
- * when a subarchive tests to see if an entry is valid it needs to
- * consult the marker file (if any) in the top-level owning archive.
- *
- * This test creates a directory structure containing a stale file
- * in a lower-level directory, creates the top-level marker file
- * as undeployment would, then creates an archive for the top level
- * and a subarchive for the lower-level directory (as the next
- * deployment would). The archive and subarchive need to skip the
- * stale file.
- */
+ // Subarchives are a little tricky. The marker file lives only at
+ // the top level (because that's where undeployment puts it). So
+ // when a subarchive tests to see if an entry is valid it needs to
+ // consult the marker file (if any) in the top-level owning archive.
+ //
+ // This test creates a directory structure containing a stale file
+ // in a lower-level directory, creates the top-level marker file
+ // as undeployment would, then creates an archive for the top level
+ // and a subarchive for the lower-level directory (as the next
+ // deployment would). The archive and subarchive need to skip the
+ // stale file.
- /*
- * Create a file in the directory before creating the archive.
- */
+ // Create a file in the directory before creating the archive.
final File oldDir = new File(archiveDir, SUBARCHIVE_NAME);
final File oldFile = new File(oldDir, STALE_ENTRY);
oldFile.getParentFile().mkdirs();
oldFile.createNewFile();
- /*
- * Mimic what undeployment does by creating a marker file for the
- * archive recording the pre-existing file.
- */
+ // Mimic what undeployment does by creating a marker file for the
+ // archive recording the pre-existing file.
FileArchive.StaleFileManager.Util.markDeletedArchive(archiveDir);
- /*
- * Now create the archive and subarchive on top of the directories
- * which already exist and contain the stale file and directory.
- */
+ // Now create the archive and subarchive on top of the directories
+ // which already exist and contain the stale file and directory.
final ArchiveAndSubarchive archives = createAndPopulateArchiveAndSubarchive();
- checkArchive((FileArchive) archives.parent, archives.fullExpectedEntryNames);
-
- checkArchive((FileArchive) archives.subarchive, usualExpectedSubarchiveEntryNames);
+ checkArchive(archives.parent, archives.fullExpectedEntryNames);
+ checkArchive(archives.subarchive, usualExpectedSubarchiveEntryNames);
getListOfFilesCheckForLogRecord((FileArchive) archives.parent, archives.fullExpectedEntryNames);
@@ -348,64 +308,41 @@
*/
@Test
public void testNormalCreate() throws Exception {
- System.out.println("testNormalCreate");
-
createAndPopulateAndCheckArchive(usualEntryNames);
}
@Test
public void testCreateWithOlderLeftoverEntry() throws Exception {
- System.out.println("testCreateWithOlderLeftoverEntry");
final ReadableArchive instance = createWithOlderLeftoverEntry(usualEntryNames);
-
getListOfFilesCheckForLogRecord((FileArchive) instance, usualExpectedEntryNames);
-
-
}
@Test
public void testCreateWithOlderLeftoverEntryWhichIsCreatedAgain() throws Exception {
- System.out.println("testCreateWithOlderLeftoverEntryWhichIsCreatedAgain");
final FileArchive instance = (FileArchive) createWithOlderLeftoverEntry(usualEntryNames);
-
- /*
- * Now add the stale entry explicitly which should make it valid.
- */
- final OutputStream os = instance.putNextEntry(STALE_ENTRY);
- os.write("No longer stale!".getBytes());
- os.close();
-
+ // Now add the stale entry explicitly which should make it valid.
+ try (OutputStream os = instance.putNextEntry(STALE_ENTRY)) {
+ os.write("No longer stale!".getBytes());
+ }
checkArchive(instance, usualExpectedEntryNamesWithOverwrittenStaleEntry);
}
private ReadableArchive createWithOlderLeftoverEntry(final Set<String> entryNames) throws Exception {
-
- /*
- * Create a file in the directory before creating the archive.
- */
+ // Create a file in the directory before creating the archive.
final File oldFile = new File(archiveDir, STALE_ENTRY);
oldFile.getParentFile().mkdirs();
oldFile.createNewFile();
- /*
- * Mimic what undeployment does by creating a marker file for the
- * archive recording the pre-existing file.
- */
+ // Mimic what undeployment does by creating a marker file for the
+ // archive recording the pre-existing file.
FileArchive.StaleFileManager.Util.markDeletedArchive(archiveDir);
- /*
- * Now create the archive. The archive should not see the old file.
- */
+ // Now create the archive. The archive should not see the old file.
return createAndPopulateArchive(entryNames);
}
@Test
public void testCreateWithOlderLeftoverEntryAndThenOpen() throws Exception {
- if (! OS.isWindows()) {
- System.out.println("Skipping (as successful) testCreateWithOlderLeftoverEntryAndThenOpen because this is not a Windows system");
- return;
- }
- System.out.println("testCreateWithOlderLeftoverEntryAndThenOpen");
createWithOlderLeftoverEntry(usualEntryNames);
final FileArchive openedArchive = new FileArchive();
openedArchive.open(archiveDir.toURI());
@@ -415,7 +352,6 @@
@Test
public void testOpenWithPreexistingDir() throws Exception {
- System.out.println("testOpenWithPreexistingDir");
createPreexistingDir();
final FileArchive openedArchive = new FileArchive();
openedArchive.open(archiveDir.toURI());
@@ -447,83 +383,50 @@
return new File(interveningDir,interveningDirNames[interveningDirNames.length - 1]);
}
- @Ignore
@Test
public void testInaccessibleDirectoryInFileArchive() throws Exception {
- final String vendorURLText = System.getProperty("java.vendor.url");
- if (vendorURLText != null && vendorURLText.contains("ibm")) {
- /*
- * The IBM Java implementation seems not to work correctly with
- * File.setReadable. So report this test
- */
- System.out.println("Skipping testInaccessibleDirectoryInFileArchive (as successful) because the Java vendor seems to be IBM");
- return;
- }
- /*
- * FileArchive will log a warning if it cannot list the files in the
- * directory. Here's the message key it will use.
- */
- final String EXPECTED_LOG_KEY = "enterprise.deployment.nullFileList";
- System.out.println("testInaccessibleDirectoryInFileArchive");
-
final FileArchive archive = (FileArchive) createAndPopulateArchive(usualEntryNames);
- /*
- * Now make the lower-level directory impossible to execute - therefore
- * the attempt to list the files should fail.
- */
+ // Now make the lower-level directory impossible to execute - therefore
+ // the attempt to list the files should fail.
final File lower = new File(archiveDir, "lower");
lower.setExecutable(false, false);
- final boolean canRead = lower.setReadable(false, false);
- if ( ! canRead) {
- /*
- * If we cannot change the permissions then the test will fail.
- * We'd like to dynamically ignore this test but that's very involved
- * and requirea a custom test runner and notifier. So we just
- * say the test passes.
- */
- return;
- }
+ assertTrue(lower.setReadable(false, false));
- /*
- * Try to list the files. This should fail with our logger getting
- * one record.
- */
- final Vector<String> fileList = new Vector<String>();
+ // Try to list the files. This should fail with our logger getting one record.
+ final Vector<String> fileList = new Vector<>();
handler.flush();
archive.getListOfFiles(lower, fileList, null /* embeddedArchives */, deplLogger);
List<LogRecord> logRecords = handler.logRecords();
- if (logRecords.isEmpty()) {
- fail("FileArchive logged no message about being unable to list files; expected " + EXPECTED_LOG_KEY);
- }
- assertEquals("FileArchive did not log expected message (re: being unable to list files)",
- EXPECTED_LOG_KEY, logRecords.get(0).getMessage());
- /*
- * Change the protection back.
- */
+ assertThat("FileArchive logged no message about being unable to list files; expected " + EXPECTED_LOG_KEY,
+ logRecords, not(emptyIterable()));
+ assertEquals(EXPECTED_LOG_KEY, logRecords.get(0).getMessage(),
+ "FileArchive did not log expected message (re: being unable to list files)");
+ // Change the protection back.
lower.setExecutable(true, false);
lower.setReadable(true, false);
handler.flush();
archive.getListOfFiles(lower, fileList, null, deplLogger);
- assertTrue("FileArchive was incorrectly unable to list files; error key in log record:" +
- (logRecords.isEmpty() ? "" : logRecords.get(0).getMessage()),
- logRecords.isEmpty());
-
+ assertTrue(logRecords.isEmpty(),
+ "FileArchive was incorrectly unable to list files; error key in log record:" + logRecords);
}
private static class RecordingHandler extends Handler {
- private final List<LogRecord> records = new ArrayList<LogRecord>();
+ private final List<LogRecord> records = new ArrayList<>();
+ @Override
public void close() {
records.clear();
}
+ @Override
public void flush() {
records.clear();
}
+ @Override
public void publish(LogRecord record) {
records.add(record);
}
diff --git a/nucleus/deployment/common/src/test/java/com/sun/enterprise/deployment/deploy/shared/InputJarArchiveTest.java b/nucleus/deployment/common/src/test/java/com/sun/enterprise/deployment/deploy/shared/InputJarArchiveTest.java
index bb1f95e..e7feb0f 100644
--- a/nucleus/deployment/common/src/test/java/com/sun/enterprise/deployment/deploy/shared/InputJarArchiveTest.java
+++ b/nucleus/deployment/common/src/test/java/com/sun/enterprise/deployment/deploy/shared/InputJarArchiveTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -17,12 +18,12 @@
package com.sun.enterprise.deployment.deploy.shared;
import com.sun.enterprise.deployment.deploy.shared.InputJarArchive.CollectionWrappedEnumeration;
+
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -36,135 +37,66 @@
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
+
import org.glassfish.api.deployment.archive.ReadableArchive;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- *
* @author Tim
*/
public class InputJarArchiveTest {
private static final String NESTED_JAR_ENTRY_NAME = "nested/archive.jar";
- public InputJarArchiveTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
/**
* Test of getArchiveSize method, of class InputJarArchive.
*/
@Test
public void testCollectionWrappedEnumerationSimple() {
- System.out.println("collection wrapped enumeration - simple iterator test");
final Enumeration<String> e = testEnum();
-
- CollectionWrappedEnumeration<String> cwe = new CollectionWrappedEnumeration<String>(
- new CollectionWrappedEnumeration.EnumerationFactory() {
-
- @Override
- public Enumeration enumeration() {
- return e;
- }
-
- });
-
- ArrayList<String> answer = new ArrayList<String>(cwe);
- assertEquals("resulting array list != original", testStringsAsArrayList(), answer);
+ CollectionWrappedEnumeration<String> cwe = new CollectionWrappedEnumeration<>(() -> e);
+ ArrayList<String> answer = new ArrayList<>(cwe);
+ assertEquals(testStringsAsArrayList(), answer, "resulting array list != original");
}
@Test
public void testCollectionWrappedEnumerationInitialSize() {
- System.out.println("collection wrapped enumeration - initial size() call");
final Enumeration<String> e = testEnum();
-
- CollectionWrappedEnumeration<String> cwe = new CollectionWrappedEnumeration<String>(
- new CollectionWrappedEnumeration.EnumerationFactory() {
-
- @Override
- public Enumeration enumeration() {
- return e;
- }
-
- });
-
+ CollectionWrappedEnumeration<String> cwe = new CollectionWrappedEnumeration<>(() -> e);
int size = cwe.size();
- ArrayList<String> answer = new ArrayList<String>(cwe);
- assertEquals("array list of size " + size + " after initial size != original", testStringsAsArrayList(), answer);
+ ArrayList<String> answer = new ArrayList<>(cwe);
+ assertEquals(testStringsAsArrayList(), answer, "array list of size " + size + " after initial size != original");
}
@Test
public void testCollectionWrappedEnumerationMiddleSize() {
- System.out.println("collection wrapped enumeration - middle size() call");
-
- CollectionWrappedEnumeration<String> cwe = new CollectionWrappedEnumeration<String>(
- new CollectionWrappedEnumeration.EnumerationFactory() {
-
- @Override
- public Enumeration enumeration() {
- return testEnum();
- }
-
- });
-
- ArrayList<String> answer = new ArrayList<String>();
+ CollectionWrappedEnumeration<String> cwe = new CollectionWrappedEnumeration<>(() -> testEnum());
+ ArrayList<String> answer = new ArrayList<>();
Iterator<String> it = cwe.iterator();
-
answer.add(it.next());
answer.add(it.next());
answer.add(it.next());
int size = cwe.size();
answer.add(it.next());
answer.add(it.next());
-
- assertEquals("array list of size " + size + " after middle size call != original", testStringsAsArrayList(), answer);
+ assertEquals(testStringsAsArrayList(), answer, "array list of size " + size + " after middle size call != original");
}
@Test
public void testCollectionWrappedEnumerationEndSize() {
- System.out.println("collection wrapped enumeration - end size() call");
-
- CollectionWrappedEnumeration<String> cwe = new CollectionWrappedEnumeration<String>(
- new CollectionWrappedEnumeration.EnumerationFactory() {
-
- @Override
- public Enumeration enumeration() {
- return testEnum();
- }
-
- });
-
- List<String> answer = new ArrayList<String>();
+ CollectionWrappedEnumeration<String> cwe = new CollectionWrappedEnumeration<>(() -> testEnum());
+ List<String> answer = new ArrayList<>();
Iterator<String> it = cwe.iterator();
-
answer.add(it.next());
answer.add(it.next());
answer.add(it.next());
answer.add(it.next());
answer.add(it.next());
int size = cwe.size();
-
- assertEquals("array list of size " + size + " after middle size call != original", testStringsAsArrayList(), answer);
+ assertEquals(testStringsAsArrayList(), answer,
+ "array list of size " + size + " after middle size call != original");
}
private ReadableArchive getArchiveForTest() throws IOException {
@@ -181,66 +113,43 @@
}
@Test
- public void testTopLevelDirEntryNamesForInputJarArchive() {
- try {
- System.out.println("top-level directory entry names in InputJarArchive");
- final ReadableArchive arch = getArchiveForTest();
- final Set<String> returnedNames = new HashSet<String>(arch.getDirectories());
- assertEquals("Returned top-level directories do not match expected", testJarTopLevelDirEntryNames(), returnedNames);
- retireArchive(arch);
- } catch (IOException ex) {
- ex.printStackTrace(System.out);
- fail("Error during test");
- }
+ public void testTopLevelDirEntryNamesForInputJarArchive() throws Exception {
+ final ReadableArchive arch = getArchiveForTest();
+ final Set<String> returnedNames = new HashSet<>(arch.getDirectories());
+ assertEquals(testJarTopLevelDirEntryNames(), returnedNames,
+ "Returned top-level directories do not match expected");
+ retireArchive(arch);
}
@Test
- public void testNonDirEnryNames() {
- try {
- System.out.println("non-directory entry names in InputJarArchive");
- final ReadableArchive arch = getArchiveForTest();
- final Set<String> returnedNames = new HashSet<String>(setFromEnumeration(arch.entries()));
- assertEquals("Returned non-directory entry names do not match expected", testStandAloneArchiveJarNonDirEntryNames(), returnedNames);
- retireArchive(arch);
- } catch (IOException ex) {
- ex.printStackTrace(System.out);
- fail("Error during test");
- }
+ public void testNonDirEnryNames() throws Exception {
+ final ReadableArchive arch = getArchiveForTest();
+ final Set<String> returnedNames = new HashSet<>(setFromEnumeration(arch.entries()));
+ assertEquals(testStandAloneArchiveJarNonDirEntryNames(), returnedNames,
+ "Returned non-directory entry names do not match expected");
+ retireArchive(arch);
}
@Test
- public void testNestedTopLevelDirEntryNames() {
- try {
- System.out.println("nested top-level directory entry names in InputJarArchive");
- final ReadableArchive arch = getArchiveForTest();
- ReadableArchive subArchive = arch.getSubArchive(NESTED_JAR_ENTRY_NAME);
+ public void testNestedTopLevelDirEntryNames() throws Exception {
+ final ReadableArchive arch = getArchiveForTest();
+ ReadableArchive subArchive = arch.getSubArchive(NESTED_JAR_ENTRY_NAME);
- final Set<String> returnedNames = new HashSet<String>(subArchive.getDirectories());
- assertEquals("Returned nested top-level directories do not match expected",
- testJarTopLevelDirEntryNames(), returnedNames);
- retireArchive(arch);
- } catch (IOException ex) {
- ex.printStackTrace(System.out);
- fail("Error during test");
- }
+ final Set<String> returnedNames = new HashSet<>(subArchive.getDirectories());
+ assertEquals(testJarTopLevelDirEntryNames(), returnedNames,
+ "Returned nested top-level directories do not match expected");
+ retireArchive(arch);
}
@Test
- public void testNestedNonDirEntryNames() {
- try {
- System.out.println("nested non-directory entry names in InputJarArchive");
- final ReadableArchive arch = getArchiveForTest();
- ReadableArchive subArchive = arch.getSubArchive(NESTED_JAR_ENTRY_NAME);
+ public void testNestedNonDirEntryNames() throws Exception {
+ final ReadableArchive arch = getArchiveForTest();
+ ReadableArchive subArchive = arch.getSubArchive(NESTED_JAR_ENTRY_NAME);
- final Set<String> returnedNames = new HashSet<String>(
- setFromEnumeration(subArchive.entries()));
- assertEquals("Returned nested non-directories do not match expected",
- testSubArchiveNonDirEntryNames(), returnedNames);
- retireArchive(arch);
- } catch (IOException ex) {
- ex.printStackTrace(System.out);
- fail("Error during test");
- }
+ final Set<String> returnedNames = new HashSet<>(setFromEnumeration(subArchive.entries()));
+ assertEquals(testSubArchiveNonDirEntryNames(), returnedNames,
+ "Returned nested non-directories do not match expected");
+ retireArchive(arch);
}
private File createTestJAR() throws IOException {
@@ -261,10 +170,8 @@
// Note that these entries in the test JAR are empty - we just need to test the names
}
- /*
- * Now create a nested JAR within the main test JAR. For simplicity
- * use the same entry names as the outer JAR.
- */
+ // Now create a nested JAR within the main test JAR. For simplicity
+ // use the same entry names as the outer JAR.
final JarEntry nestedJarEntry = new JarEntry(NESTED_JAR_ENTRY_NAME);
jos.putNextEntry(nestedJarEntry);
@@ -281,16 +188,13 @@
jos.write(baos.toByteArray());
jos.closeEntry();
-
jos.close();
return tempJAR;
}
private static Enumeration<String> testEnum() {
- Enumeration<String> e = Collections.enumeration(testStringsAsArrayList());
-
- return e;
+ return Collections.enumeration(testStringsAsArrayList());
}
private static List<String> testStringsAsArrayList() {
@@ -306,25 +210,26 @@
"topLevelDir/secondLevelDir/thirdLevelNonDir");
}
+
private static Set<String> testJarTopLevelDirEntryNames() {
- return new HashSet(Arrays.asList(
- "topLevelDir/"));
+ return Set.of("topLevelDir/");
}
+
private static Set<String> testSubArchiveNonDirEntryNames() {
- return new HashSet(Arrays.asList(
- "topLevelNonDir", "topLevelDir/secondLevelNonDir",
- "topLevelDir/secondLevelDir/thirdLevelNonDir"));
+ return Set.of("topLevelNonDir", "topLevelDir/secondLevelNonDir", "topLevelDir/secondLevelDir/thirdLevelNonDir");
}
+
private static Set<String> testStandAloneArchiveJarNonDirEntryNames() {
- final Set<String> result = testSubArchiveNonDirEntryNames();
+ final Set<String> result = new HashSet<>(testSubArchiveNonDirEntryNames());
result.add(NESTED_JAR_ENTRY_NAME);
return result;
}
+
private static <T> Set<T> setFromEnumeration(final Enumeration<T> e) {
- final Set<T> result = new HashSet<T>();
+ final Set<T> result = new HashSet<>();
while (e.hasMoreElements()) {
result.add(e.nextElement());
}
diff --git a/nucleus/deployment/common/src/test/java/com/sun/enterprise/deployment/deploy/shared/JarArchiveTest.java b/nucleus/deployment/common/src/test/java/com/sun/enterprise/deployment/deploy/shared/JarArchiveTest.java
index ef23060..4ee178e 100644
--- a/nucleus/deployment/common/src/test/java/com/sun/enterprise/deployment/deploy/shared/JarArchiveTest.java
+++ b/nucleus/deployment/common/src/test/java/com/sun/enterprise/deployment/deploy/shared/JarArchiveTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -14,94 +15,46 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
package com.sun.enterprise.deployment.deploy.shared;
import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- *
* @author Tim
*/
public class JarArchiveTest {
- public JarArchiveTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
-
-
/**
* Test of getName method, of class JarArchive.
+ * @throws Exception
*/
@Test
- public void shortSubPaths() {
- try {
- URI uri = new URI("jar:///a/b/c/d.war");
- assertEquals("d", JarArchive.getName(uri));
- } catch (URISyntaxException ex) {
- fail("URI improperly formated" + ex.getInput());
- }
+ public void shortSubPaths() throws Exception {
+ URI uri = new URI("jar:///a/b/c/d.war");
+ assertEquals("d", JarArchive.getName(uri));
}
+
@Test
- public void noFileType() {
- try {
- URI uri = new URI("jar:///aaaaa/bbbb/cc/x");
- assertEquals("x", JarArchive.getName(uri));
- } catch (URISyntaxException ex) {
- fail("URI improperly formated" + ex.getInput());
- }
+ public void noFileType() throws Exception {
+ URI uri = new URI("jar:///aaaaa/bbbb/cc/x");
+ assertEquals("x", JarArchive.getName(uri));
}
+
@Test
- public void trailingDot() {
- try {
- URI uri = new URI("jar:///ww/xx/yy/z.");
- assertEquals("z", JarArchive.getName(uri));
- } catch (URISyntaxException ex) {
- fail("URI improperly formated" + ex.getInput());
- }
+ public void trailingDot() throws Exception {
+ URI uri = new URI("jar:///ww/xx/yy/z.");
+ assertEquals("z", JarArchive.getName(uri));
}
+
@Test
- public void multipleDots() {
- try {
- URI uri = new URI("jar:///ww/xx/yy/this.is.my.jar");
- assertEquals("this.is.my", JarArchive.getName(uri));
- } catch (URISyntaxException ex) {
- fail("URI improperly formated" + ex.getInput());
- }
-
+ public void multipleDots() throws Exception {
+ URI uri = new URI("jar:///ww/xx/yy/this.is.my.jar");
+ assertEquals("this.is.my", JarArchive.getName(uri));
}
-
}
diff --git a/nucleus/deployment/common/src/test/java/org/glassfish/deployment/versioning/VersioningUtilsTest.java b/nucleus/deployment/common/src/test/java/org/glassfish/deployment/versioning/VersioningUtilsTest.java
index 84bdaa3..bc51143 100644
--- a/nucleus/deployment/common/src/test/java/org/glassfish/deployment/versioning/VersioningUtilsTest.java
+++ b/nucleus/deployment/common/src/test/java/org/glassfish/deployment/versioning/VersioningUtilsTest.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,505 +17,357 @@
package org.glassfish.deployment.versioning;
+import com.sun.enterprise.config.serverbeans.AppTenants;
+import com.sun.enterprise.config.serverbeans.Application;
+import com.sun.enterprise.config.serverbeans.ApplicationExtension;
+import com.sun.enterprise.config.serverbeans.ApplicationRef;
+import com.sun.enterprise.config.serverbeans.Engine;
+import com.sun.enterprise.config.serverbeans.Module;
+import com.sun.enterprise.config.serverbeans.Resources;
+
import java.beans.PropertyVetoException;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.io.File;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.junit.jupiter.api.Test;
import org.jvnet.hk2.config.ConfigBeanProxy;
import org.jvnet.hk2.config.TransactionFailure;
import org.jvnet.hk2.config.types.Property;
-import org.glassfish.api.deployment.DeployCommandParameters;
-import com.sun.enterprise.config.serverbeans.*;
-import com.sun.enterprise.config.serverbeans.Module;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
- *
* @author Romain GRECOURT - SERLI (romain.grecourt@serli.com)
*/
-
public class VersioningUtilsTest {
private static final String APPLICATION_NAME = "foo";
+ // the list of all foo versions
+ private static final List<String> FOO_VERSIONS = List.of(
+ // ALPHA versions
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.0",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.1",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.2",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.1.0",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.1.1",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.1.2",
+ // BETA versions
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.0",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.1",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.2",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.1.0",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.1.1",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.1.2",
+ // RC versions
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.0",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.1",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.2",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.0",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.1",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.2"
+ );
+
/**
- * Test of {@link org.glassfish.deployment.versioning.VersioningUtils.getUntaggedName}
+ * Test of {@link VersioningUtils#getUntaggedName(String)}
*
* Check the extraction of untagged names from different application names
* as version identifier, version expression or untagged application name.
- *
- * @throws VersioningSyntaxException if the given application name had some
- * critical patterns.
*/
@Test
- public void testGetUntaggedName() throws VersioningSyntaxException {
-
+ public void testGetUntaggedName() throws Exception {
// test an application name that contains a version expression
// application name : foo:RC-*
- String expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-"
- + VersioningUtils.EXPRESSION_WILDCARD;
-
- String result = VersioningUtils.getUntaggedName(expression);
- assertEquals(APPLICATION_NAME, result);
+ final String expression = APPLICATION_NAME
+ + VersioningUtils.EXPRESSION_SEPARATOR
+ + "RC-" + VersioningUtils.EXPRESSION_WILDCARD;
+ assertEquals(APPLICATION_NAME, VersioningUtils.getUntaggedName(expression));
// test an application name that contains a version identifier
// application name : foo:RC-1.0.0
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.0";
-
- result = VersioningUtils.getUntaggedName(expression);
- assertEquals(APPLICATION_NAME, result);
+ assertEquals(APPLICATION_NAME,
+ VersioningUtils.getUntaggedName(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.0"));
// test an application name that is an untagged version name
// application name : foo
- expression = APPLICATION_NAME;
-
- result = VersioningUtils.getUntaggedName(expression);
- assertEquals(APPLICATION_NAME, result);
+ assertEquals(APPLICATION_NAME, VersioningUtils.getUntaggedName(APPLICATION_NAME));
// test an application name containing a critical pattern
// application name : foo:
- expression = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR;
-
- try {
- result = VersioningUtils.getUntaggedName(expression);
- fail("the getUntagged method did not throw a VersioningDeploymentSyntaxException");
- }
- catch(VersioningSyntaxException e){}
+ assertThrows(VersioningSyntaxException.class,
+ () -> VersioningUtils.getUntaggedName(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR));
}
/**
- * Test of {@link org.glassfish.deployment.versioning.VersioningUtils.getExpression}
+ * Test of {@link VersioningUtils#getExpression(String)}
*
* Check the extraction of version expression / identifier from different
* application names.
- *
- * @throws VersioningSyntaxException if the given application name had some
- * critical patterns.
*/
@Test
- public void testGetExpression() throws VersioningSyntaxException {
-
+ public void testGetExpression() throws Exception {
// test an application name containing a critical pattern
// application name : foo:
- String expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR;
-
- try {
- String result = VersioningUtils.getExpression(expression);
- fail("the getExpression method did not throw a VersioningSyntaxException");
- } catch (VersioningSyntaxException e) {}
+ assertThrows(VersioningSyntaxException.class,
+ () -> VersioningUtils.getExpression(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR));
// test an application name containing a critical pattern
// application name : foo:RC-1;0.0
- expression = APPLICATION_NAME
+ final String expression = APPLICATION_NAME
+ VersioningUtils.EXPRESSION_SEPARATOR
+ "RC-1"
+ VersioningUtils.EXPRESSION_SEPARATOR
+ "0.0";
-
- try {
- String result = VersioningUtils.getExpression(expression);
- //fail("the getExpression method did not throw a VersioningSyntaxException");
- } catch (VersioningSyntaxException e) {}
+ assertEquals("RC-1:0.0", VersioningUtils.getExpression(expression));
}
/**
- * Test of {@link org.glassfish.deployment.versioning.VersioningUtils.getVersions}
+ * Test of {@link VersioningUtils#getVersions(String, List)}
*
* Check the extraction of a set of version(s) from a set of applications.
*/
@Test
- public void testGetVersions() throws VersioningException {
+ public void testGetVersions() throws Exception {
// the set of applications
- List<Application> listApplications = new ArrayList<Application>();
+ final List<Application> listApplications = new ArrayList<>();
listApplications.add(new ApplicationTest(APPLICATION_NAME));
- listApplications.add(new ApplicationTest(APPLICATION_NAME+
- VersioningUtils.EXPRESSION_SEPARATOR+"BETA-1.0.0"));
- listApplications.add(new ApplicationTest(APPLICATION_NAME+
- VersioningUtils.EXPRESSION_SEPARATOR+"RC-1.0.0"));
- listApplications.add(new ApplicationTest(APPLICATION_NAME+
- "_RC-1.0.0"));
- listApplications.add(new ApplicationTest(APPLICATION_NAME+
- ";RC-1.0.0"));
- listApplications.add(new ApplicationTest(APPLICATION_NAME+
- ".RC-1.0.0"));
- listApplications.add(new ApplicationTest(APPLICATION_NAME+
- "-RC-1.0.0"));
- listApplications.add(new ApplicationTest(APPLICATION_NAME+
- APPLICATION_NAME));
+ listApplications
+ .add(new ApplicationTest(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.0"));
+ listApplications.add(new ApplicationTest(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.0"));
+ listApplications.add(new ApplicationTest(APPLICATION_NAME + "_RC-1.0.0"));
+ listApplications.add(new ApplicationTest(APPLICATION_NAME + ";RC-1.0.0"));
+ listApplications.add(new ApplicationTest(APPLICATION_NAME + ".RC-1.0.0"));
+ listApplications.add(new ApplicationTest(APPLICATION_NAME + "-RC-1.0.0"));
+ listApplications.add(new ApplicationTest(APPLICATION_NAME + APPLICATION_NAME));
// the expected set of versions
- List<String> expResult = new ArrayList<String>();
+ final List<String> expResult = new ArrayList<>();
expResult.add(APPLICATION_NAME);
- expResult.add(APPLICATION_NAME+
- VersioningUtils.EXPRESSION_SEPARATOR+"BETA-1.0.0");
- expResult.add(APPLICATION_NAME+
- VersioningUtils.EXPRESSION_SEPARATOR+"RC-1.0.0");
+ expResult.add(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.0");
+ expResult.add(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.0");
- List result = VersioningUtils.getVersions(APPLICATION_NAME, listApplications);
+ final List<String> result = VersioningUtils.getVersions(APPLICATION_NAME, listApplications);
assertEquals(expResult, result);
}
/**
- * Test of {@link org.glassfish.deployment.versioning.VersioningUtils.matchExpression}
+ * Test of {@link VersioningUtils#matchExpression(List, String)}
+ * TEST TYPE 1 : expression matching all the versions
*
* Check the matching of version expression over a set of version
- *
- * @throws VersioningException for registration issues, or if the given
- * application name had some
- * critical patterns.
*/
@Test
- public void testMatchExpression() throws VersioningException {
- // the set of all foo versions
- List<String> listVersion = new ArrayList<String>();
- // ALPHA versions
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.0");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.1");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.2");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.1.0");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.1.1");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.1.2");
- // BETA versions
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.0");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.1");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.2");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.1.0");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.1.1");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.1.2");
- // RC versions
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.0");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.1");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.2");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.0");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.1");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.2");
-
- // **************************************************
- // TEST TYPE 1 : expression matching all the versions
- // **************************************************
-
- // the expected set of matched version is all the versions
- List expResult = new ArrayList<String>(listVersion);
-
- // ------------------------
+ public void testMatchExpression() throws Exception {
// application name foo:*
- // ------------------------
-
String expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR
- + VersioningUtils.EXPRESSION_WILDCARD;
+ + VersioningUtils.EXPRESSION_SEPARATOR
+ + VersioningUtils.EXPRESSION_WILDCARD;
- List result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(expResult, result);
+ assertEquals(FOO_VERSIONS, VersioningUtils.matchExpression(FOO_VERSIONS, expression));
- // -----------------------------
// application name foo:******
- // -----------------------------
-
expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD;
+ + VersioningUtils.EXPRESSION_SEPARATOR
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD;
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(expResult, result);
+ assertEquals(FOO_VERSIONS, VersioningUtils.matchExpression(FOO_VERSIONS, expression));
+ }
- // *****************************************************
- // TEST TYPE 2 : expression matching all the RC versions
- // *****************************************************
- expResult.clear();
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.0");
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.1");
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.2");
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.0");
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.1");
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.2");
+ /**
+ * Test of {@link VersioningUtils#matchExpression(List, String)}
+ * TEST TYPE 2 : expression matching all the RC versions
+ *
+ * Check the matching of version expression over a set of version
+ */
+ @Test
+ public void testMatchExpression_RC() throws Exception {
+ // the expected set of matched version is all the versions
+ final List<String> expResult = List.of(
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.0",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.1",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.2",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.0",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.1",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.1.2"
+ );
- // --------------------------
// application name foo:RC*
- // --------------------------
+ final String expressionFooRCAny = APPLICATION_NAME
+ + VersioningUtils.EXPRESSION_SEPARATOR + "RC"
+ + VersioningUtils.EXPRESSION_WILDCARD;
+ assertEquals(expResult, VersioningUtils.matchExpression(FOO_VERSIONS, expressionFooRCAny));
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC"
- + VersioningUtils.EXPRESSION_WILDCARD;
-
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(expResult, result);
-
- // --------------------------
// application name foo:*RC*
- // --------------------------
+ final String expressionFooAnyRCAny = APPLICATION_NAME
+ + VersioningUtils.EXPRESSION_SEPARATOR
+ + VersioningUtils.EXPRESSION_WILDCARD + "RC"
+ + VersioningUtils.EXPRESSION_WILDCARD;
+ assertEquals(expResult, VersioningUtils.matchExpression(FOO_VERSIONS, expressionFooAnyRCAny));
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR
- + VersioningUtils.EXPRESSION_WILDCARD + "RC"
- + VersioningUtils.EXPRESSION_WILDCARD;
-
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(expResult, result);
-
- // -------------------------------
// application name foo:***RC***
- // -------------------------------
+ final String expression = APPLICATION_NAME
+ + VersioningUtils.EXPRESSION_SEPARATOR
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD + "RC"
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD;
+ assertEquals(expResult, VersioningUtils.matchExpression(FOO_VERSIONS, expression));
+ }
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD + "RC"
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD;
+ /**
+ * Test of {@link VersioningUtils#matchExpression(List, String)}
+ * TEST TYPE 3 : expression matching all the 1.0.2 versions
+ *
+ * Check the matching of version expression over a set of version
+ */
+ @Test
+ public void testMatchExpression_102() throws Exception {
+ final List<String> expResult = List.of(
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.2",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.2",
+ APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.2"
+ );
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(expResult, result);
-
- // ********************************************************
- // TEST TYPE 3 : expression matching all the 1.0.2 versions
- // ********************************************************
- expResult.clear();
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.2");
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1.0.2");
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "RC-1.0.2");
-
- // ------------------------------
// application name foo:*-1.0.2
- // ------------------------------
+ final String expression1 = APPLICATION_NAME
+ + VersioningUtils.EXPRESSION_SEPARATOR
+ + VersioningUtils.EXPRESSION_WILDCARD + "-1.0.2";
+ assertEquals(expResult, VersioningUtils.matchExpression(FOO_VERSIONS, expression1));
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR
- + VersioningUtils.EXPRESSION_WILDCARD + "-1.0.2";
-
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(expResult, result);
-
- // ----------------------------------
// application name foo:***1.0.2***
- // ----------------------------------
+ final String expression2 = APPLICATION_NAME
+ + VersioningUtils.EXPRESSION_SEPARATOR
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD + "-1.0.2"
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD;
+ assertEquals(expResult, VersioningUtils.matchExpression(FOO_VERSIONS, expression2));
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD + "-1.0.2"
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD;
-
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(expResult, result);
-
- // ----------------------------------
// application name foo:***1*0*2***
- // ----------------------------------
+ final String expression3 = APPLICATION_NAME
+ + VersioningUtils.EXPRESSION_SEPARATOR
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD + "1"
+ + VersioningUtils.EXPRESSION_WILDCARD + "0"
+ + VersioningUtils.EXPRESSION_WILDCARD + "2"
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD
+ + VersioningUtils.EXPRESSION_WILDCARD;
+ assertEquals(expResult, VersioningUtils.matchExpression(FOO_VERSIONS, expression3));
+ }
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD + "1"
- + VersioningUtils.EXPRESSION_WILDCARD + "0"
- + VersioningUtils.EXPRESSION_WILDCARD + "2"
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD
- + VersioningUtils.EXPRESSION_WILDCARD;
+ /**
+ * Test of {@link VersioningUtils#matchExpression(List, String)}
+ * TEST TYPE 4 : identifier as expression
+ *
+ * Check the matching of version expression over a set of version
+ */
+ @Test
+ public void testMatchExpression_asterisks() throws Exception {
+ final List<String> expResult = List.of(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.2");
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(expResult, result);
-
- // **************************************
- // TEST TYPE 4 : identifier as expression
- // **************************************
- expResult.clear();
- expResult.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.2");
-
- // ----------------------------------
// application name foo:ALPHA-1.0.2
- // ----------------------------------
+ String expression = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.2";
+ assertEquals(expResult, VersioningUtils.matchExpression(FOO_VERSIONS, expression));
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "ALPHA-1.0.2";
+ final List<String> listVersion = new ArrayList<>();
+ listVersion.add(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "abc-1");
+ listVersion.add(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "abc-2");
+ listVersion.add(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "abc-3");
+ listVersion.add(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "bac-4");
+ listVersion.add(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "cab-5");
+ listVersion.add(APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "cba-6");
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(expResult, result);
+ expression = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "a*";
+ assertThat(VersioningUtils.matchExpression(listVersion, expression), hasSize(3));
- // *****************************************
- // check for pattern matching like issue 12132
- // *****************************************
+ expression = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "*a";
+ assertThat(VersioningUtils.matchExpression(listVersion, expression), hasSize(0));
- listVersion.clear();
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "abc-1");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "abc-2");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "abc-3");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "bac-4");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "cab-5");
- listVersion.add(APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "cba-6");
+ expression = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "a****1";
+ assertThat(VersioningUtils.matchExpression(listVersion, expression), hasSize(1));
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "a*";
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(result.size(), 3);
+ expression = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "*-*";
+ assertThat(VersioningUtils.matchExpression(listVersion, expression), hasSize(6));
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "*a";
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(result.size(), 0);
+ expression = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "*-4";
+ assertThat(VersioningUtils.matchExpression(listVersion, expression), hasSize(1));
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "a****1";
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(result.size(), 1);
+ expression = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "b*";
+ assertThat(VersioningUtils.matchExpression(listVersion, expression), hasSize(1));
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "*-*";
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(result.size(), 6);
-
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "*-4";
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(result.size(), 1);
-
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "b*";
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(result.size(), 1);
-
- expression = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR + "b*";
- result = VersioningUtils.matchExpression(listVersion, expression);
- assertEquals(result.size(), 1);
+ expression = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + "b*";
+ assertThat(VersioningUtils.matchExpression(listVersion, expression), hasSize(1));
}
/**
* Test of getIdentifier method, of class VersioningUtils.
- * @throws VersioningException
*/
@Test
- public void testGetIdentifier() throws VersioningException {
- // *****************************************
+ public void testGetIdentifier() throws Exception {
// check for getIdentifier with and without '*'
- // *****************************************
- String versionIdentifier = "BETA-1";
- String appName = "foo" + VersioningUtils.EXPRESSION_SEPARATOR + versionIdentifier;
- try{
- VersioningUtils.checkIdentifier(appName);
- } catch (VersioningSyntaxException e){
- fail(e.getMessage());
- }
+ assertDoesNotThrow(
+ () -> VersioningUtils.checkIdentifier("foo" + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-1"));
- String versionExpression = "BETA-*";
- appName = "foo" + VersioningUtils.EXPRESSION_SEPARATOR + versionExpression;
- try {
- VersioningUtils.checkIdentifier(appName);
- fail("the getIdentifier method should not accept version with '*' in it.");
- } catch (VersioningException e) {}
+ assertThrows(VersioningException.class,
+ () -> VersioningUtils.checkIdentifier("foo" + VersioningUtils.EXPRESSION_SEPARATOR + "BETA-*"));
}
+
/**
* Test of getRepositoryName method, of class VersioningUtils.
- * @throws VersioningSyntaxException
*/
@Test
- public void testGetRepositoryName() throws VersioningSyntaxException {
- String versionIdentifier = "RC-1.0.0";
-
- String appName = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR
- + versionIdentifier;
-
- String expectedResult = APPLICATION_NAME
- + VersioningUtils.REPOSITORY_DASH
- + versionIdentifier;
-
- String result = "";
- result = VersioningUtils.getRepositoryName(appName);
- assertEquals(expectedResult, result);
-
- //==========================================
-
- versionIdentifier = "RC:1.0.0";
- appName = APPLICATION_NAME
- + VersioningUtils.EXPRESSION_SEPARATOR
- + versionIdentifier;
-
- expectedResult = APPLICATION_NAME
- + VersioningUtils.REPOSITORY_DASH
+ public void testGetRepositoryName() throws Exception {
+ {
+ String versionIdentifier = "RC-1.0.0";
+ String appName = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + versionIdentifier;
+ String expectedResult = APPLICATION_NAME + VersioningUtils.REPOSITORY_DASH + versionIdentifier;
+ String result = VersioningUtils.getRepositoryName(appName);
+ assertEquals(expectedResult, result);
+ }
+ {
+ String versionIdentifier = "RC:1.0.0";
+ String appName = APPLICATION_NAME + VersioningUtils.EXPRESSION_SEPARATOR + versionIdentifier;
+ String expectedResult = APPLICATION_NAME + VersioningUtils.REPOSITORY_DASH
+ versionIdentifier.replace(":", VersioningUtils.REPOSITORY_DASH);
-
- result = VersioningUtils.getRepositoryName(appName);
- assertEquals(expectedResult, result);
+ String result = VersioningUtils.getRepositoryName(appName);
+ assertEquals(expectedResult, result);
+ }
}
- /**
+ /**
* Test of isUntagged method, of class VersioningUtils.
*/
@Test
public void testIsUntagged() {
- try{
- VersioningUtils.isUntagged(APPLICATION_NAME+":");
- fail("an exception has to be thrown when '"+APPLICATION_NAME+":' is supplied to isUntagged method");
- }
- catch(VersioningException e){}
- try{
- VersioningUtils.isUntagged(":BETA");
- fail("an exception has to be thrown when ':BETA' is supplied to isUntagged method");
- }
- catch(VersioningException e){}
- try{
- VersioningUtils.isUntagged("::");
- fail("an exception has to be thrown when '::' is supplied to isUntagged method");
- }
- catch(VersioningException e){}
- assertEquals(false, VersioningUtils.isUntagged(null));
- assertEquals(false, VersioningUtils.isUntagged(APPLICATION_NAME+":*"));
- assertEquals(false, VersioningUtils.isUntagged(APPLICATION_NAME+":BETA*"));
- assertEquals(false, VersioningUtils.isUntagged(APPLICATION_NAME+":BETA"));
- assertEquals(false, VersioningUtils.isUntagged(APPLICATION_NAME+"::"));
- assertEquals(false, VersioningUtils.isUntagged(APPLICATION_NAME+":BETA:2"));
+ assertThrows(VersioningException.class, () -> VersioningUtils.isUntagged(APPLICATION_NAME + ":"));
+ assertThrows(VersioningException.class, () -> VersioningUtils.isUntagged(":BETA"));
+ assertThrows(VersioningException.class, () -> VersioningUtils.isUntagged("::"));
+ assertFalse(VersioningUtils.isUntagged(null));
+ assertFalse(VersioningUtils.isUntagged(APPLICATION_NAME+":*"));
+ assertFalse(VersioningUtils.isUntagged(APPLICATION_NAME+":BETA*"));
+ assertFalse(VersioningUtils.isUntagged(APPLICATION_NAME+":BETA"));
+ assertFalse(VersioningUtils.isUntagged(APPLICATION_NAME+"::"));
+ assertFalse(VersioningUtils.isUntagged(APPLICATION_NAME+":BETA:2"));
}
/**
@@ -522,10 +375,10 @@
*/
@Test
public void testIsVersionExpression() {
- assertEquals(false, VersioningUtils.isVersionExpression(null));
- assertEquals(false, VersioningUtils.isVersionExpression(APPLICATION_NAME));
- assertEquals(true, VersioningUtils.isVersionExpression(APPLICATION_NAME+":BETA"));
- assertEquals(true, VersioningUtils.isVersionExpression(APPLICATION_NAME+"::"));
+ assertFalse(VersioningUtils.isVersionExpression(null));
+ assertFalse(VersioningUtils.isVersionExpression(APPLICATION_NAME));
+ assertTrue(VersioningUtils.isVersionExpression(APPLICATION_NAME+":BETA"));
+ assertTrue(VersioningUtils.isVersionExpression(APPLICATION_NAME+"::"));
}
/**
@@ -533,17 +386,17 @@
*/
@Test
public void testIsVersionIdentifier() {
- assertEquals(false, VersioningUtils.isVersionIdentifier(APPLICATION_NAME+":*"));
- assertEquals(false, VersioningUtils.isVersionIdentifier(APPLICATION_NAME+":BETA*"));
+ assertFalse(VersioningUtils.isVersionIdentifier(APPLICATION_NAME+":*"));
+ assertFalse(VersioningUtils.isVersionIdentifier(APPLICATION_NAME+":BETA*"));
}
// this class is used to fake the List<Application>
// so we can call the VersioningUtils.matchExpression
// with an home made set of applications.
private class ApplicationTest implements Application {
- private String name;
+ private final String name;
- public ApplicationTest(String value){
+ public ApplicationTest(final String value){
this.name = value;
}
@@ -558,17 +411,17 @@
}
@Override
- public void setAppTenants(AppTenants appTenants) {
+ public void setAppTenants(final AppTenants appTenants) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public void setName(String value) throws PropertyVetoException{
+ public void setName(final String value) throws PropertyVetoException{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public void setResources(Resources resources){
+ public void setResources(final Resources resources){
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -583,7 +436,7 @@
}
@Override
- public void setContextRoot(String value) throws PropertyVetoException {
+ public void setContextRoot(final String value) throws PropertyVetoException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -593,7 +446,7 @@
}
@Override
- public void setLocation(String value) throws PropertyVetoException {
+ public void setLocation(final String value) throws PropertyVetoException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -603,7 +456,7 @@
}
@Override
- public void setObjectType(String value) throws PropertyVetoException {
+ public void setObjectType(final String value) throws PropertyVetoException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -613,7 +466,7 @@
}
@Override
- public void setEnabled(String value) throws PropertyVetoException {
+ public void setEnabled(final String value) throws PropertyVetoException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -623,7 +476,7 @@
}
@Override
- public void setLibraries(String value) throws PropertyVetoException {
+ public void setLibraries(final String value) throws PropertyVetoException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -633,7 +486,7 @@
}
@Override
- public void setAvailabilityEnabled(String value) throws PropertyVetoException {
+ public void setAvailabilityEnabled(final String value) throws PropertyVetoException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -643,7 +496,7 @@
}
@Override
- public void setAsyncReplication (String value) throws PropertyVetoException {
+ public void setAsyncReplication (final String value) throws PropertyVetoException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -653,7 +506,7 @@
}
@Override
- public void setDirectoryDeployed(String value) throws PropertyVetoException {
+ public void setDirectoryDeployed(final String value) throws PropertyVetoException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -663,7 +516,7 @@
}
@Override
- public void setDescription(String value) throws PropertyVetoException {
+ public void setDescription(final String value) throws PropertyVetoException {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -673,7 +526,7 @@
}
@Override
- public void setDeploymentOrder(String value) throws PropertyVetoException{
+ public void setDeploymentOrder(final String value) throws PropertyVetoException{
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -688,7 +541,7 @@
}
@Override
- public Module getModule(String moduleName) {
+ public Module getModule(final String moduleName) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -698,7 +551,7 @@
}
@Override
- public DeployCommandParameters getDeployParameters(ApplicationRef appRef) {
+ public DeployCommandParameters getDeployParameters(final ApplicationRef appRef) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -719,12 +572,12 @@
}
@Override
- public boolean containsSnifferType(String snifferType) {
+ public boolean containsSnifferType(final String snifferType) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public void recordFileLocations(File app, File plan) {
+ public void recordFileLocations(final File app, final File plan) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -749,17 +602,17 @@
}
@Override
- public Property getProperty(String name) {
+ public Property getProperty(final String name) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public String getPropertyValue(String name) {
+ public String getPropertyValue(final String name) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public String getPropertyValue(String name, String defaultValue) {
+ public String getPropertyValue(final String name, final String defaultValue) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -769,18 +622,18 @@
}
@Override
- public <T extends ConfigBeanProxy> T getParent(Class<T> type) {
+ public <T extends ConfigBeanProxy> T getParent(final Class<T> type) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public <T extends ConfigBeanProxy> T createChild(Class<T> type)
+ public <T extends ConfigBeanProxy> T createChild(final Class<T> type)
throws TransactionFailure {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public ConfigBeanProxy deepCopy(ConfigBeanProxy parent) {
+ public ConfigBeanProxy deepCopy(final ConfigBeanProxy parent) {
throw new UnsupportedOperationException("Not supported yet.");
}
@@ -790,32 +643,32 @@
}
@Override
- public <T extends ApplicationExtension> T getExtensionByType(Class<T> type) {
+ public <T extends ApplicationExtension> T getExtensionByType(final Class<T> type) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public <T extends ApplicationExtension> List<T> getExtensionsByType(Class<T> type) {
+ public <T extends ApplicationExtension> List<T> getExtensionsByType(final Class<T> type) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public Property addProperty(Property prprt) {
+ public Property addProperty(final Property prprt) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public Property lookupProperty(String string) {
+ public Property lookupProperty(final String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public Property removeProperty(String string) {
+ public Property removeProperty(final String string) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public Property removeProperty(Property prprt) {
+ public Property removeProperty(final Property prprt) {
throw new UnsupportedOperationException("Not supported yet.");
}
}