Search in sources :

Example 1 with JDBCLoginService

use of org.eclipse.jetty.security.JDBCLoginService in project jetty.project by eclipse.

the class JdbcLoginServiceTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    _docRoot = MavenTestingUtils.getTargetTestingDir("loginservice-test");
    FS.ensureDirExists(_docRoot);
    File content = new File(_docRoot, "input.txt");
    try (FileOutputStream out = new FileOutputStream(content)) {
        out.write(_content.getBytes("utf-8"));
    }
    //drop any tables that might have existed
    File scriptFile = MavenTestingUtils.getTestResourceFile("droptables.sql");
    int result = DatabaseLoginServiceTestServer.runscript(scriptFile);
    //ignore result, if the tables dont already exist, derby spits out an error
    //create the tables afresh
    scriptFile = MavenTestingUtils.getTestResourceFile("createdb.sql");
    result = DatabaseLoginServiceTestServer.runscript(scriptFile);
    assertThat("runScript result", result, is(0));
    File jdbcRealmFile = MavenTestingUtils.getTestResourceFile("jdbcrealm.properties");
    LoginService loginService = new JDBCLoginService(__realm, jdbcRealmFile.getAbsolutePath());
    _testServer = new DatabaseLoginServiceTestServer();
    _testServer.setResourceBase(_docRoot.getAbsolutePath());
    _testServer.setLoginService(loginService);
    _testServer.start();
    _baseUri = _testServer.getBaseUri();
}
Also used : FileOutputStream(java.io.FileOutputStream) JDBCLoginService(org.eclipse.jetty.security.JDBCLoginService) File(java.io.File) JDBCLoginService(org.eclipse.jetty.security.JDBCLoginService) LoginService(org.eclipse.jetty.security.LoginService) BeforeClass(org.junit.BeforeClass)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 JDBCLoginService (org.eclipse.jetty.security.JDBCLoginService)1 LoginService (org.eclipse.jetty.security.LoginService)1 BeforeClass (org.junit.BeforeClass)1