// Path: server/src/fat/java/com/ibm/ws/lars/rest/RepositoryContext.java
// enum Protocol {
//     HTTP, HTTPS
// }
// 
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
// 
//     public static final String SCRIPT;
// 
//     public static final String DB_PORT;
//     public static final String LIBERTY_PORT_HTTP;
//     public static final String LIBERTY_PORT_HTTPS;
//     public static final String TEST_DB_NAME;
//     public static final String LARS_APPLICATION_ROOT;
//     public static final String BASEURL_LIBERTY_PORT_HTTP;
// 
//     static {
//         if (System.getProperty("os.name").startsWith("Windows")) {
//             SCRIPT = "client/bin/larsClient.bat";
//         } else {
//             SCRIPT = "client/bin/larsClient";
//         }
// 
//         Properties defaultConfig = new Properties();
//         InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
//         try {
//             defaultConfig.load(propsStream);
//         } catch (IOException e) {
//             // Can't recover from this
//             throw new RuntimeException("Unable to find config.properties file for database/server configuration");
//         }
// 
//         DB_PORT = defaultConfig.getProperty("testMongoPort");
//         LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
//         LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
//         TEST_DB_NAME = defaultConfig.getProperty("testDbName");
//         LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
//         BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
// 
//     }
// 
//     public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
// 
//     public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
// 
//     public static final String ADMIN_USERNAME = "admin";
// 
//     public static final String ADMIN_PASSWORD = "passw0rd";
// 
//     public static final String USER_ROLE_USERNAME = "user";
// 
//     public static final String USER_ROLE_PASSWORD = "passw0rd";
// 
//     public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
// 
//     public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
// 
//     private static DB fatDB = null;
// 
//     public static int countLines(String input) {
//         int lines = 0;
//         // If the last character isn't \n, add one, as that will make
//         // the count match what you would normally expect
//         if (input.charAt(input.length() - 1) != '\n') {
//             lines = 1;
//         }
//         while (true) {
//             int nlIndex = input.indexOf('\n');
//             if (nlIndex == -1) {
//                 break;
//             }
//             lines++;
//             input = input.substring(nlIndex + 1);
//         }
//         return lines;
//     }
// 
//     public static Object[][] getRestFixtureParameters() {
//         List<Object[]> objectList = new ArrayList<Object[]>();
// 
//         objectList.add(new Object[] { FAT_REPO });
// 
//         return objectList.toArray(new Object[objectList.size()][]);
//     }
// 
//     /**
//      * Returns a connection to the mongo database used for fat tests.
//      * <p>
//      * The same connection instance is returned to all tests.
//      * <p>
//      * We never explicitly close the client and rely on the connection being closed when the JVM
//      * exits.
//      */
//     public static synchronized DB getMongoDB() throws UnknownHostException {
//         if (fatDB == null) {
//             MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
//             fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
//         }
//         return fatDB;
//     }
// }


import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.ibm.ws.lars.rest.RepositoryContext.Protocol;
import com.ibm.ws.lars.rest.model.Asset.State;
import com.ibm.ws.lars.testutils.FatUtils;
import static com.ibm.ws.lars.rest.AssetUtils.getTestAsset;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.apache.http.client.methods.HttpGet;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.fasterxml.jackson.core.JsonFactory;
/*******************************************************************************
 * Copyright (c) 2015 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.lars.rest;





/**
 * Tests for the LARS front page
 */
@RunWith(Parameterized.class)
public class FrontPageTest {

    @Rule
    public final RepositoryContext repository;

    @Parameters(name = "{0}")
    public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][] { { Protocol.HTTP, "http://localhost:" + FatUtils.LIBERTY_PORT_HTTP },
                                             { Protocol.HTTPS, "https://localhost:" + FatUtils.LIBERTY_PORT_HTTPS } });
    }

    private final String baseUrl;

    public FrontPageTest(Protocol protocol, String url) {
        this.repository = RepositoryContext.createAsAdmin(protocol);
        this.baseUrl = url;
    }

// Path: server/src/fat/java/com/ibm/ws/lars/rest/RepositoryContext.java
// enum Protocol {
//     HTTP, HTTPS
// }
// 
// Path: test-utils/src/main/java/com/ibm/ws/lars/testutils/FatUtils.java
// public class FatUtils {
// 
//     public static final String SCRIPT;
// 
//     public static final String DB_PORT;
//     public static final String LIBERTY_PORT_HTTP;
//     public static final String LIBERTY_PORT_HTTPS;
//     public static final String TEST_DB_NAME;
//     public static final String LARS_APPLICATION_ROOT;
//     public static final String BASEURL_LIBERTY_PORT_HTTP;
// 
//     static {
//         if (System.getProperty("os.name").startsWith("Windows")) {
//             SCRIPT = "client/bin/larsClient.bat";
//         } else {
//             SCRIPT = "client/bin/larsClient";
//         }
// 
//         Properties defaultConfig = new Properties();
//         InputStream propsStream = FatUtils.class.getClassLoader().getResourceAsStream("config.properties");
//         try {
//             defaultConfig.load(propsStream);
//         } catch (IOException e) {
//             // Can't recover from this
//             throw new RuntimeException("Unable to find config.properties file for database/server configuration");
//         }
// 
//         DB_PORT = defaultConfig.getProperty("testMongoPort");
//         LIBERTY_PORT_HTTP = defaultConfig.getProperty("testLibertyPortHTTP");
//         LIBERTY_PORT_HTTPS = defaultConfig.getProperty("testLibertyPortHTTPS");
//         TEST_DB_NAME = defaultConfig.getProperty("testDbName");
//         LARS_APPLICATION_ROOT = defaultConfig.getProperty("larsApplicationRoot");
//         BASEURL_LIBERTY_PORT_HTTP = defaultConfig.getProperty("baseUrlLibertyPortHTTP");
// 
//     }
// 
//     public static final String SERVER_URL = "http://localhost:" + LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
// 
//     public static final String DEFAULT_HOST_AND_PORT = "localhost:" + DB_PORT;
// 
//     public static final String ADMIN_USERNAME = "admin";
// 
//     public static final String ADMIN_PASSWORD = "passw0rd";
// 
//     public static final String USER_ROLE_USERNAME = "user";
// 
//     public static final String USER_ROLE_PASSWORD = "passw0rd";
// 
//     public static final String BASEURL_SERVER_URL = "http://localhost:" + BASEURL_LIBERTY_PORT_HTTP + LARS_APPLICATION_ROOT;
// 
//     public static final RepositoryFixture FAT_REPO = LarsRepositoryFixture.createFixture(SERVER_URL, "1", ADMIN_USERNAME, ADMIN_PASSWORD, USER_ROLE_USERNAME, USER_ROLE_PASSWORD);
// 
//     private static DB fatDB = null;
// 
//     public static int countLines(String input) {
//         int lines = 0;
//         // If the last character isn't \n, add one, as that will make
//         // the count match what you would normally expect
//         if (input.charAt(input.length() - 1) != '\n') {
//             lines = 1;
//         }
//         while (true) {
//             int nlIndex = input.indexOf('\n');
//             if (nlIndex == -1) {
//                 break;
//             }
//             lines++;
//             input = input.substring(nlIndex + 1);
//         }
//         return lines;
//     }
// 
//     public static Object[][] getRestFixtureParameters() {
//         List<Object[]> objectList = new ArrayList<Object[]>();
// 
//         objectList.add(new Object[] { FAT_REPO });
// 
//         return objectList.toArray(new Object[objectList.size()][]);
//     }
// 
//     /**
//      * Returns a connection to the mongo database used for fat tests.
//      * <p>
//      * The same connection instance is returned to all tests.
//      * <p>
//      * We never explicitly close the client and rely on the connection being closed when the JVM
//      * exits.
//      */
//     public static synchronized DB getMongoDB() throws UnknownHostException {
//         if (fatDB == null) {
//             MongoClient mongoClient = new MongoClient("localhost:" + FatUtils.DB_PORT, new MongoClientOptions.Builder().build());
//             fatDB = mongoClient.getDB(FatUtils.TEST_DB_NAME);
//         }
//         return fatDB;
//     }
// }


// Path: server/src/fat/java/com/ibm/ws/lars/rest/FrontPageTest.java
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.ibm.ws.lars.rest.RepositoryContext.Protocol;
import com.ibm.ws.lars.rest.model.Asset.State;
import com.ibm.ws.lars.testutils.FatUtils;
import static com.ibm.ws.lars.rest.AssetUtils.getTestAsset;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.apache.http.client.methods.HttpGet;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import com.fasterxml.jackson.core.JsonFactory;

/*******************************************************************************
 * Copyright (c) 2015 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.lars.rest;





/**
 * Tests for the LARS front page
 */
@RunWith(Parameterized.class)
public class FrontPageTest {

    @Rule
    public final RepositoryContext repository;

    @Parameters(name = "{0}")
    public static Collection<Object[]> data() {
        return Arrays.asList(new Object[][] { { Protocol.HTTP, "http://localhost:" + FatUtils.LIBERTY_PORT_HTTP },
                                             { Protocol.HTTPS, "https://localhost:" + FatUtils.LIBERTY_PORT_HTTPS } });
    }

    private final String baseUrl;

    public FrontPageTest(Protocol protocol, String url) {
        this.repository = RepositoryContext.createAsAdmin(protocol);
        this.baseUrl = url;
    }

    @Test