/*
 * Copyright to the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *         http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.rioproject.impl.system.capability;

import org.junit.Assert;
import org.junit.Test;
import org.rioproject.config.PlatformCapabilityConfig;
import org.rioproject.config.PlatformLoader;
import org.rioproject.impl.system.capability.PlatformCapabilityWriter;
import org.rioproject.system.capability.PlatformCapability;

import java.io.File;

/**
 * @author Dennis Reedy
 */
public class PlatformCapabilityWriterTest {

    @Test
    public void testWrite() throws Exception {
        String cwd = System.getProperty("user.dir");
        File target = new File(cwd, "target");
        File platform = new File(target, "platform-file");
        platform.mkdirs();
        PlatformCapability pCap = new PlatformCapability();
        pCap.define(PlatformCapability.NAME, "Foo");
        pCap.define(PlatformCapability.VERSION, "1.0");
        pCap.setClassPath(new String[]{cwd+File.separator+"target"+File.separator+"classes"+File.separator});
        PlatformCapabilityWriter writer = new PlatformCapabilityWriter();
        String fileName = writer.write(pCap, platform.getPath());
        Assert.assertNotNull(fileName);
        PlatformLoader platformLoader = new PlatformLoader();
        PlatformCapabilityConfig[] pCapConfigs = platformLoader.parsePlatform(platform.getPath());
        Assert.assertNotNull(pCapConfigs);
        Assert.assertEquals(1, pCapConfigs.length);

    }
}

@@ -813,79 +813,8 @@
 er;%0A
-import org.rioproject.impl.system.capability.PlatformCapabilityWriter;%0A
 impo
@@ -861,32 +861,32 @@
 formCapability;%0A
+
 %0Aimport java.io.
@@ -1116,22 +1116,21 @@
 e(cwd, %22
-target
+build
 %22);%0A    
@@ -1439,22 +1439,21 @@
 arator+%22
-target
+build
 %22+File.s
@@ -1489,32 +1489,50 @@
 ator%7D);%0A        
+String fileName = 
 PlatformCapabili
@@ -1538,82 +1538,8 @@
 ityW
-riter writer = new PlatformCapabilityWriter();%0A        String fileName = w
 rite

Change working directory