// Path: client-lib/src/main/java/com/ibm/ws/repository/connections/SingleFileRepositoryConnection.java
// public class SingleFileRepositoryConnection extends AbstractRepositoryConnection implements RepositoryConnection {
// 
//     private final File jsonFile;
// 
//     public SingleFileRepositoryConnection(File jsonFile) {
//         this.jsonFile = jsonFile;
//     }
// 
//     @Override
//     public String getRepositoryLocation() {
//         return jsonFile.getAbsolutePath();
//     }
// 
//     @Override
//     public RepositoryReadableClient createClient() {
//         return new SingleFileClient(jsonFile);
//     }
// 
//     /**
//      * Create an empty single file Repository connection.
//      * <p>
//      * Repository data will be stored in {@code jsonFile} which must not exist and will be created by this method.
//      *
//      * @param jsonFile the location for the repository file
//      * @return the repository connection
//      * @throws IOException if {@code jsonFile} already exists or there is a problem creating the file
//      */
//     public static SingleFileRepositoryConnection createEmptyRepository(File jsonFile) throws IOException {
//         if (jsonFile.exists()) {
//             throw new IOException("Cannot create empty repository as the file already exists: " + jsonFile.getAbsolutePath());
//         }
// 
//         OutputStreamWriter writer = null;
//         try {
//             writer = new OutputStreamWriter(new FileOutputStream(jsonFile), "UTF-8");
//             writer.write("[]");
//         } finally {
//             if (writer != null) {
//                 writer.close();
//             }
//         }
// 
//         return new SingleFileRepositoryConnection(jsonFile);
//     }
// 
// }


import static org.hamcrest.Matchers.emptyCollectionOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import java.io.File;
import org.junit.After;
import org.junit.Test;
import com.ibm.ws.repository.connections.SingleFileRepositoryConnection;
import com.ibm.ws.repository.resources.RepositoryResource;
/*******************************************************************************
 * Copyright (c) 2017 IBM Corp.
 *
 * 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 com.ibm.ws.repository.connections.test;





/**
 * Tests specific to the SingleFileRepositoryConnection
 */
public class SingleFileRepositoryConnectionTest {

    private static final File FILE = new File("testSingleFileRepo");

    @After
    public void cleanup() {
        if (FILE.exists()) {
            FILE.delete();
        }
    }

    @Test
    public void testNoFileCheckStatus() {
// Path: client-lib/src/main/java/com/ibm/ws/repository/connections/SingleFileRepositoryConnection.java
// public class SingleFileRepositoryConnection extends AbstractRepositoryConnection implements RepositoryConnection {
// 
//     private final File jsonFile;
// 
//     public SingleFileRepositoryConnection(File jsonFile) {
//         this.jsonFile = jsonFile;
//     }
// 
//     @Override
//     public String getRepositoryLocation() {
//         return jsonFile.getAbsolutePath();
//     }
// 
//     @Override
//     public RepositoryReadableClient createClient() {
//         return new SingleFileClient(jsonFile);
//     }
// 
//     /**
//      * Create an empty single file Repository connection.
//      * <p>
//      * Repository data will be stored in {@code jsonFile} which must not exist and will be created by this method.
//      *
//      * @param jsonFile the location for the repository file
//      * @return the repository connection
//      * @throws IOException if {@code jsonFile} already exists or there is a problem creating the file
//      */
//     public static SingleFileRepositoryConnection createEmptyRepository(File jsonFile) throws IOException {
//         if (jsonFile.exists()) {
//             throw new IOException("Cannot create empty repository as the file already exists: " + jsonFile.getAbsolutePath());
//         }
// 
//         OutputStreamWriter writer = null;
//         try {
//             writer = new OutputStreamWriter(new FileOutputStream(jsonFile), "UTF-8");
//             writer.write("[]");
//         } finally {
//             if (writer != null) {
//                 writer.close();
//             }
//         }
// 
//         return new SingleFileRepositoryConnection(jsonFile);
//     }
// 
// }


// Path: client-lib-tests/src/test/java/com/ibm/ws/repository/connections/test/SingleFileRepositoryConnectionTest.java
import static org.hamcrest.Matchers.emptyCollectionOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import java.io.File;
import org.junit.After;
import org.junit.Test;
import com.ibm.ws.repository.connections.SingleFileRepositoryConnection;
import com.ibm.ws.repository.resources.RepositoryResource;

/*******************************************************************************
 * Copyright (c) 2017 IBM Corp.
 *
 * 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 com.ibm.ws.repository.connections.test;





/**
 * Tests specific to the SingleFileRepositoryConnection
 */
public class SingleFileRepositoryConnectionTest {

    private static final File FILE = new File("testSingleFileRepo");

    @After
    public void cleanup() {
        if (FILE.exists()) {
            FILE.delete();
        }
    }

    @Test
    public void testNoFileCheckStatus() {
        SingleFileRepositoryConnection repo = new SingleFileRepositoryConnection(FILE);