Skip to content

Commit

Permalink
Merge pull request #514 from phantomjinx/TEIIDDES-2678
Browse files Browse the repository at this point in the history
Teiiddes 2678
  • Loading branch information
phantomjinx committed Oct 8, 2015
2 parents 0145dd8 + 579c5f8 commit 24f7b00
Show file tree
Hide file tree
Showing 8 changed files with 619 additions and 550 deletions.
835 changes: 419 additions & 416 deletions plugins/org.teiid.designer.ui/launch/Designer Windows.launch

Large diffs are not rendered by default.

Expand Up @@ -243,9 +243,15 @@ public boolean equals(Object obj) {
*/
public void save( final ZipOutputStream out) throws Exception {
String zipName = getPath().toString();
//
// Path on Windows will be using backslashes but zip entries only
// deal with forward slashes so need to replace with them.
//
zipName = zipName.replace(DOUBLE_BACK_SLASH, FORWARD_SLASH);

// Need to strip off the leading delimeter if it exists, else a "jar" extract command will result in models
// being located at the file system "root" folder.
if( zipName.startsWith("/") ) { //$NON-NLS-1$
if (zipName.startsWith(FORWARD_SLASH)) {
zipName = zipName.substring(1, zipName.length());
}
final ZipEntry zipEntry = new ZipEntry(zipName);
Expand Down
Expand Up @@ -179,6 +179,13 @@ public IFile findFileInWorkspace() {
public void save( final ZipOutputStream out) throws Exception {
// Name of VDB entry
String zipName = getPath().toOSString();

//
// Path on Windows will be using backslashes but zip entries only
// deal with forward slashes so need to replace with them.
//
zipName = zipName.replace(DOUBLE_BACK_SLASH, FORWARD_SLASH);

// Need to strip off the leading delimeter if it exists, else a "jar" extract command will result in models
// being located at the file system "root" folder.
if(zipName.startsWith(StringConstants.FORWARD_SLASH)) {
Expand Down
280 changes: 151 additions & 129 deletions plugins/org.teiid.designer.vdb/src/org/teiid/designer/vdb/XmiVdb.java

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions scripts/build-common.xml
Expand Up @@ -99,7 +99,7 @@

<echo>Executing maven in directory @{dir} with arguments: ${rwsResult}</echo>

<exec dir="@{dir}" executable="mvn.bat" osfamily="windows" failifexecutionfails="true" failonerror="true">
<exec dir="@{dir}" executable="mvn.cmd" osfamily="windows" failifexecutionfails="true" failonerror="true">
<arg line="${rwsResult}" />
</exec>
<exec dir="@{dir}" executable="mvn" osfamily="mac" failifexecutionfails="true" failonerror="true">
Expand All @@ -111,4 +111,4 @@

</sequential>
</macrodef>
</project>
</project>
8 changes: 7 additions & 1 deletion target-platform/build.sh
Expand Up @@ -34,6 +34,7 @@ echo "Script directory = $SCRIPT_DIR"
# Set root directory to be the parent of this.
#
ROOT_DIR="$SCRIPT_DIR/../.."
echo "Root Directory: $ROOT_DIR"

#
# By default debug is turned off
Expand Down Expand Up @@ -63,7 +64,12 @@ SRC_DIR="${SCRIPT_DIR}"
# Ensure it only contains teiid related artifacts and
# does not clutter up user's existing $HOME/.m2 repository
#
LOCAL_REPO="${ROOT_DIR}/m2-repository"
if [ -z "${M2_REPO}" ]; then
LOCAL_REPO="${ROOT_DIR}/m2-repository"
else
LOCAL_REPO=${M2_REPO}
fi
echo "Local Repository: $LOCAL_REPO"

#
# Maven command
Expand Down
Expand Up @@ -252,7 +252,13 @@ private void mockFile() throws Exception {
mockFileProperties(resource, realFile, wkspPath, IResource.FILE);

IFile resourceFile = getResourceFile();
when(resourceFile.getContents()).thenReturn(new FileInputStream(realFile));
when(resourceFile.getContents()).thenAnswer(new Answer<InputStream>() {
@Override
public InputStream answer(InvocationOnMock invocation) throws Throwable {
assertNotNull(realFile);
return new FileInputStream(realFile);
}
});
}

/**
Expand Down
Expand Up @@ -28,6 +28,7 @@
import java.io.InputStream;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Set;
import java.util.zip.Checksum;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
Expand Down Expand Up @@ -55,6 +56,7 @@
import org.teiid.designer.roles.DataRole;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion.Version;
import org.teiid.designer.vdb.VdbEntry.Synchronization;
import org.teiid.designer.vdb.VdbFileEntry.FileEntryType;
import org.teiid.designer.vdb.file.ValidationVersionCallback;
import org.teiid.designer.vdb.file.VdbFileProcessor;
import org.teiid.designer.vdb.manifest.EntryElement;
Expand Down Expand Up @@ -424,6 +426,7 @@ public void testSaveOfUdfVdb() throws Exception {

Vdb udfVdb = new XmiVdb(udfVdbBuilder.getResourceFile());
udfVdb.save();
udfVdb.close();

boolean udfJarPresent = false;
boolean empSourceModelPresent = false;
Expand Down Expand Up @@ -485,6 +488,22 @@ public void testSaveOfUdfVdb() throws Exception {
assertTrue(empSourceModelPresent);
assertEquals(2, indexFilesPresent);
assertTrue(empViewModelPresent);

//
// Create a new vdb based on the newly-saved version to check everything is intact
//
udfVdbBuilder = new MockFileBuilder(udfVdbCopy);
udfVdbBuilder.addToModelWorkspace(modelWorkspaceMock);
when(udfVdbBuilder.getResourceFile().findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE)).thenReturn(new IMarker[0]);
when(udfVdbBuilder.getResourceFile().createMarker(IMarker.PROBLEM)).thenReturn(mock(IMarker.class));

udfVdb = new XmiVdb(udfVdbBuilder.getResourceFile());
Set<VdbFileEntry> udfJarEntries = udfVdb.getUdfJarEntries();
assertEquals(1, udfJarEntries.size());
VdbFileEntry udfEntry = udfJarEntries.iterator().next();
assertEquals("name_builder", udfEntry.getName());
assertEquals(File.separator + "lib" + File.separator + "name_builder.jar", udfEntry.getPath().toOSString());
assertEquals(FileEntryType.UDFJar, udfEntry.getFileType());
}

@Test
Expand Down

0 comments on commit 24f7b00

Please sign in to comment.