Skip to content

Commit

Permalink
Cleanup, removal of some unneeded resources
Browse files Browse the repository at this point in the history
  • Loading branch information
jottinger committed Sep 14, 2012
1 parent 1723485 commit 99141b6
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 16 deletions.
1 change: 0 additions & 1 deletion android-sensor/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello android-sensor!</string>
<string name="app_name">OSAS light sensor</string>
<string name="routerUrlLabel">URL to which to send data</string>
<string name="routerUrl">http://192.168.1.115:8080/sensor-web/sensor</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package com.redhat.osas.sensor.connector;

import org.testng.annotations.Test;

public class HttpConnectorTest {

public void testHttpConnector() {
public void atestHttpConnector() {
System.out.println("in test");
Connector connector=new HttpConnector();
Connector connector = new HttpConnector();
System.out.println("we have the connector");
connector.connect("http://192.168.1.115:8080/sensor-web/sensor");
connector.publish("{\"latitude\":2,\"longitude\":1,\"level\":78,\"timestamp\":12912912}");
}

public static void main(String[] args) {
new HttpConnectorTest().testHttpConnector();
new HttpConnectorTest().atestHttpConnector();
}
}
83 changes: 77 additions & 6 deletions sensor-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enable third-party plugin if using Maven < 2.1) -->
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
<!-- Specify the JBoss AS directory to be the JBOSS_HOME environment
variable -->
<jboss.home>/home/jottinge/tools/jboss-as-7.1.1.Final</jboss.home>
<jbossHome>/home/jottinge/tools/jboss-as-7.1.1.Final</jbossHome>
<infinispan.version>[5.1.5.FINAL,)</infinispan.version>
<resteasy.version>2.3.4.Final</resteasy.version>
</properties>
Expand All @@ -50,6 +50,15 @@ enable third-party plugin if using Maven < 2.1) -->
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.0.2.Final</version>
<scope>import</scope>
<type>pom</type>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -214,15 +223,16 @@ given to the generated war, and hence the context root) -->
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.0.2.Final</version>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<!-- The default profile skips all tests, though you can tune it
to run just unit tests based on a custom pattern -->
<!-- Seperate profiles are provided for running all tests, including
Arquillian tests that execute in the specified container -->
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
Expand All @@ -231,14 +241,75 @@ given to the generated war, and hence the context root) -->
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.3</version>
<version>2.12</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>runtests</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-arquillian-container-managed</artifactId>
<version>7.1.1.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-dist</artifactId>
<version>7.1.1.Final</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redhat.osas.sensor.web;
package com.redhat.osas.sensor.web.external;

import com.redhat.osas.sensor.data.DataPoint;
import org.codehaus.jackson.map.ObjectMapper;
Expand All @@ -15,7 +15,7 @@
import java.io.PrintWriter;

@WebServlet("/sensor")
public class DataCollector extends HttpServlet {
public class Consumer extends HttpServlet {
@Resource(lookup = "java:comp/env/sensorData")
private CacheContainer container;
private Cache<String, DataPoint> cache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import org.infinispan.manager.CacheContainer;

import javax.annotation.Resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

@Produces(MediaType.APPLICATION_JSON)
Expand All @@ -35,4 +35,23 @@ public List<DataPoint> getData() {

return dataPoints;
}

private static final Comparator<DataPoint> comparator = new Comparator<DataPoint>() {
@Override
public int compare(DataPoint dataPoint, DataPoint dataPoint1) {
return (int) (Math.signum(1.0 * dataPoint.getTimestamp() -
dataPoint1.getTimestamp()));
}
};

@POST
@Consumes(MediaType.APPLICATION_JSON)
public void submitData(List<DataPoint> dp) {
Collections.sort(dp, comparator);
Cache<String, DataPoint> cache =
container.getCache("sensorData");
for (DataPoint dataPoint : dp) {
cache.put(dataPoint.getDeviceId(), dataPoint);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.redhat.osas.sensor.web;

import com.redhat.osas.sensor.web.external.Provider;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.fail;

@RunWith(Arquillian.class)
public class ProviderTest {
@Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addClass(Provider.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
System.out.println(war);
return war;
}

@Test
public void testConfiguration() {
fail("whoa");
}
}

0 comments on commit 99141b6

Please sign in to comment.