-
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.
Enhance test coverage and fix bug when view contains already suffix
fixes: #369
- Loading branch information
Showing
9 changed files
with
216 additions
and
53 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: 0 additions & 16 deletions
16
testsuite/src/main/java/org/eclipse/krazo/test/defaultview/DefaultViewApplication.java
This file was deleted.
Oops, something went wrong.
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
33 changes: 33 additions & 0 deletions
33
...suite/src/main/java/org/eclipse/krazo/test/defaultview/DefaultViewWithDotApplication.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,33 @@ | ||
/* | ||
* Copyright (c) 2023 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.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 DefaultViewWithDotApplication extends Application { | ||
|
||
@Override | ||
public Map<String, Object> getProperties() { | ||
return Map.of(ViewEngine.VIEW_EXTENSION, ".jsp"); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...te/src/main/java/org/eclipse/krazo/test/defaultview/DefaultViewWithoutDotApplication.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,33 @@ | ||
/* | ||
* Copyright (c) 2023 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.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 DefaultViewWithoutDotApplication extends Application { | ||
|
||
@Override | ||
public Map<String, Object> getProperties() { | ||
return Map.of(ViewEngine.VIEW_EXTENSION, "jsp"); | ||
} | ||
} |
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
85 changes: 85 additions & 0 deletions
85
testsuite/src/test/java/org/eclipse/krazo/test/DefaultViewWithoutDotIT.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,85 @@ | ||
/* | ||
* Copyright (c) 2023 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.defaultview.DefaultViewController; | ||
import org.eclipse.krazo.test.defaultview.DefaultViewWithoutDotApplication; | ||
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 DefaultViewWithoutDotIT { | ||
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() | ||
.addClasses(DefaultViewWithoutDotApplication.class, DefaultViewController.class) | ||
.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()); | ||
} | ||
|
||
@Test | ||
public void testWithAppliedExtension() throws Exception { | ||
final HtmlPage page = webClient.getPage(baseURL + "mvc/default-view/with-extension"); | ||
|
||
System.out.println(page.asXml()); | ||
|
||
assertEquals("Default-View Extension Test", page.getElementById("headline").getTextContent()); | ||
} | ||
} |
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