11package edu .harvard .iq .dataverse .api ;
22
33import edu .harvard .iq .dataverse .settings .SettingsServiceBean ;
4- import io .restassured .http .Header ;
54import io .restassured .response .Response ;
65import org .junit .jupiter .api .AfterEach ;
6+ import org .junit .jupiter .api .BeforeAll ;
77import org .junit .jupiter .api .Test ;
88
9+ import java .nio .file .Files ;
10+ import java .nio .file .Paths ;
11+
912import static org .hamcrest .CoreMatchers .*;
1013
1114public class CustomizationIT {
1215
16+ static String docroot ;
17+ @ BeforeAll
18+ public static void setup () {
19+ if (Files .exists (Paths .get ("docker-dev-volumes" ))) {
20+ docroot = "./appserver/glassfish/domains/domain1/docroot/" ;
21+ } else {
22+ // /usr/local/payara6/glassfish/domains/domain1/config
23+ docroot = "../docroot/" ;
24+ }
25+ }
1326 @ AfterEach
1427 public void after () {
1528 UtilIT .deleteSetting (SettingsServiceBean .Key .WebAnalyticsCode );
1629 }
1730
1831 @ Test
1932 public void testGetCustomAnalytics () {
20- String setting = "/usr/local/glassfish4/glassfish/domains/domain1/docroot/index.html" ;
21- //String setting = "./appserver/glassfish/domains/domain1/docroot/index.html";
33+ String setting = docroot + "index.html" ;
2234 UtilIT .setSetting (SettingsServiceBean .Key .WebAnalyticsCode , setting ).prettyPrint ();
2335
2436 Response getResponse = UtilIT .getCustomizationFile ("analytics" );
2537 getResponse .prettyPrint ();
2638 getResponse .then ().assertThat ()
27- .statusCode (404 )
28- .body (containsString ("not found. x" ));
29- //.statusCode(200)
30- //.body(containsString("<!doctype html>"));
39+ .body (containsString ("<!doctype html>" ))
40+ .statusCode (200 );
3141
3242 assert (getResponse .getHeaders ().get ("Content-Type" ).getValue ().startsWith ("text/html" ));
3343
@@ -37,13 +47,12 @@ public void testGetCustomAnalytics() {
3747 getResponse .prettyPrint ();
3848 getResponse .then ().assertThat ()
3949 .statusCode (404 )
40- .body (containsString ("not found" ));
50+ .body (containsString ("not found. " ));
4151 }
4252
4353 @ Test
4454 public void testGetCustomLogo () {
45- // String setting = "/usr/local/glassfish4/glassfish/domains/domain1/docroot/img/logo.png";
46- String setting = "./appserver/glassfish/domains/domain1/docroot/img/logo.png" ;
55+ String setting = docroot + "img/logo.png" ;
4756 UtilIT .setSetting (SettingsServiceBean .Key .LogoCustomizationFile , setting ).prettyPrint ();
4857
4958 Response getResponse = UtilIT .getCustomizationFile ("logo" );
@@ -60,6 +69,6 @@ public void testGetCustomLogo() {
6069 getResponse .prettyPrint ();
6170 getResponse .then ().assertThat ()
6271 .statusCode (404 )
63- .body (containsString ("not found" ));
72+ .body (containsString ("not found. " ));
6473 }
6574}
0 commit comments