-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Krazo default view suffix constant with spec constant
fixes: #369
- Loading branch information
Showing
6 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
testsuite/src/main/java/org/eclipse/krazo/test/defaultview/DefaultViewApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.eclipse.krazo.test.defaultview; | ||
|
||
import jakarta.mvc.engine.ViewEngine; | ||
import jakarta.ws.rs.ApplicationPath; | ||
import jakarta.ws.rs.core.Application; | ||
|
||
import java.util.Map; | ||
|
||
@ApplicationPath("mvc") | ||
public class DefaultViewApplication extends Application { | ||
|
||
@Override | ||
public Map<String, Object> getProperties() { | ||
return Map.of(ViewEngine.VIEW_EXTENSION, ".jsp"); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
testsuite/src/main/java/org/eclipse/krazo/test/defaultview/DefaultViewController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.eclipse.krazo.test.defaultview; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.mvc.Controller; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
@Controller | ||
@RequestScoped | ||
@Path("default-view") | ||
public class DefaultViewController { | ||
|
||
@GET | ||
public String index() { | ||
return "index"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<%@ page contentType="text/html;charset=UTF-8" language="java" %> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Default-View Extension Test</title> | ||
</head> | ||
<body> | ||
<h1 id="headline">Default-View Extension Test</h1> | ||
</body> | ||
</html> |
75 changes: 75 additions & 0 deletions
75
testsuite/src/test/java/org/eclipse/krazo/test/DefaultViewIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) 2014-2015 Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2018, 2019 Eclipse Krazo committers and contributors | ||
* | ||
* 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. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.eclipse.krazo.test; | ||
|
||
import com.gargoylesoftware.htmlunit.WebClient; | ||
import com.gargoylesoftware.htmlunit.html.HtmlPage; | ||
import org.eclipse.krazo.test.util.WebArchiveBuilder; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.net.URL; | ||
import java.nio.file.Paths; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Tests default view extension. | ||
* | ||
* @author Tobias Erdle | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class DefaultViewIT { | ||
private static final String WEB_INF_SRC = "src/main/resources/defaultview/"; | ||
@ArquillianResource | ||
private URL baseURL; | ||
private WebClient webClient; | ||
|
||
@Before | ||
public void setUp() { | ||
webClient = new WebClient(); | ||
webClient.getOptions() | ||
.setThrowExceptionOnFailingStatusCode(false); | ||
webClient.getOptions() | ||
.setRedirectEnabled(true); | ||
} | ||
|
||
@Deployment(testable = false, name = "default-view") | ||
public static WebArchive createDeployment() { | ||
return new WebArchiveBuilder() | ||
.addPackage("org.eclipse.krazo.test.defaultview") | ||
.addView(Paths.get(WEB_INF_SRC).resolve("views/index.jsp").toFile(), "index.jsp") | ||
.addBeansXml() | ||
.build(); | ||
} | ||
|
||
@Test | ||
public void test() throws Exception { | ||
final HtmlPage page = webClient.getPage(baseURL + "mvc/default-view"); | ||
|
||
System.out.println(page.asXml()); | ||
|
||
assertEquals("Default-View Extension Test", page.getElementById("headline").getTextContent()); | ||
} | ||
} |