Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: build

on:
push:
branches: [master]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
cache: maven
- name: Build and test
run: mvn -B verify
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2015 Ashwanth Fernando

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/crazysoftwarecoder/bigpipe.svg?branch=master)](https://travis-ci.org/crazysoftwarecoder/bigpipe)
[![build](https://github.com/crazysoftwarecoder/bigpipe/actions/workflows/build.yml/badge.svg)](https://github.com/crazysoftwarecoder/bigpipe/actions/workflows/build.yml)

## A BigPipe implementation for Java

Expand Down Expand Up @@ -73,7 +73,7 @@ public ClassA {
}
```

###Step 2
### Step 2

Define the return ViewObject for each @PageletTaskMethod

Expand All @@ -90,12 +90,12 @@ class LeftNavBarDataVO implements ViewObject { // ViewObject is just a marker in
}

public void setCategoryName(String categoryName) {

this.categoryName = categoryName;
}
}
```

###Step 3
### Step 3

In your JSP

Expand Down Expand Up @@ -123,7 +123,7 @@ In your JSP
</html>
```

###Step 4
### Step 4

Then finally in your web.xml
```xml
Expand All @@ -146,11 +146,11 @@ Then finally in your web.xml
</servlet-mapping>
```

###Step 5
### Step 5
You are all set! Go to **http://localhost:8080/app-context/url-that-you-want-serve/** and see the results.

## Example
For an example, look [here](https://github.com/crazysoftwarecoder/bigpipe/tree/master/bigpipe-java-web-example)

###License
[MIT](https://github.com/strongloop/express/blob/master/LICENSE)
## License
[MIT](LICENSE)
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void execute(final Object pageletTask, final HttpServletRequest servletRe
Preconditions.checkArgument(pageletTask!=null);

// Validate if this is a pagelet task.
if (isPageletTask(pageletTask)) {
if (isNotPageletTask(pageletTask)) {
throw new TaskExecutionException("passed in object is not a PageletTask. "
+ "Please annotate your pagelet task class with @" + PageletTask.class.getCanonicalName());
}
Expand Down Expand Up @@ -75,7 +75,7 @@ public void run() {
});
}

private boolean isPageletTask(Object obj) {
private boolean isNotPageletTask(Object obj) {
return (obj.getClass().getAnnotation(PageletTask.class)==null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,4 @@ public void doTag() throws JspException, IOException {
out.println(SETTER_JS_FUNCTION);
}

public static void main(String[] args) {
new BigPipeStartTag();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import java.io.IOException;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import javax.xml.bind.DatatypeConverter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -49,16 +49,8 @@ private void emitDivPlaceholder(String pageletName) throws IOException {
}

protected String getBase64String(String input) {
try {
byte[] inputBytes = input.getBytes("UTF-8");
String encodedString = DatatypeConverter.printBase64Binary(inputBytes);
return encodedString;
}
catch (UnsupportedEncodingException e) {
String message = "Could not transform String to UTF-8 bytes";
logger.error(e.getMessage());
throw new IllegalArgumentException(message);
}
byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8);
return Base64.getEncoder().encodeToString(inputBytes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.myseriousorganization.bigpipe.core.executor;

import org.junit.Test;

import com.myseriousorganization.bigpipe.core.annotations.PageletTask;
import com.myseriousorganization.bigpipe.core.exception.TaskExecutionException;

public class PageletTaskExecutorTest {

@PageletTask(name = "annotated")
static class AnnotatedTask {
}

static class PlainObject {
}

@Test(expected = TaskExecutionException.class)
public void rejectsObjectWithoutPageletTaskAnnotation() throws Exception {
new PageletTaskExecutor(1).execute(new PlainObject(), null);
}

@Test(expected = IllegalArgumentException.class)
public void rejectsNullTask() throws Exception {
new PageletTaskExecutor(1).execute(null, null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.myseriousorganization.bigpipe.core.executor;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Test;

import com.myseriousorganization.bigpipe.core.marker.ViewObject;

public class PageletTaskOutputHolderTest {

private PageletTaskOutputHolder holder;

@Before
public void setUp() {
holder = new PageletTaskOutputHolder();
}

@Test
public void roundTripsTheViewObject() {
ViewObject vo = new ViewObject() {};
holder.addPageletTask("left");
holder.putViewObject("left", vo);

assertSame(vo, holder.getViewObject("left"));
}

@Test
public void tracksWhichPageletsExist() {
assertFalse(holder.doesPageletExist("left"));
holder.addPageletTask("left");
assertTrue(holder.doesPageletExist("left"));
}

@Test(expected = IllegalArgumentException.class)
public void rejectsDuplicatePageletRegistration() {
holder.addPageletTask("left");
holder.addPageletTask("left");
}

@Test(expected = IllegalArgumentException.class)
public void rejectsSecondViewObjectForSamePagelet() {
holder.addPageletTask("left");
holder.putViewObject("left", new ViewObject() {});
holder.putViewObject("left", new ViewObject() {});
}

@Test(expected = IllegalArgumentException.class)
public void putForUnknownPageletFails() {
holder.putViewObject("missing", new ViewObject() {});
}

@Test(expected = IllegalArgumentException.class)
public void getForUnknownPageletFails() {
holder.getViewObject("missing");
}
}
21 changes: 14 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,27 @@
<name>The java implementation of big-pipe.</name>

<modules>
<module>bigpipe-java-web</module>
<module>bigpipe-java-web-example</module>
<module>bigpipe-java-web</module>
<module>bigpipe-java-web-example</module>
</modules>

<properties>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
</plugins>
</pluginManagement>
Expand All @@ -34,7 +41,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Loading