Skip to content

Restructure to Http library #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
149 changes: 149 additions & 0 deletions azure-functions-java-http-library/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-http-library</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>com.microsoft.maven</groupId>
<artifactId>java-8-parent</artifactId>
<version>8.0.1</version>
<relativePath></relativePath>
</parent>

<name>Microsoft Azure Functions Http Library</name>
<description>This package contains Java Http interfaces and annotations to interact with Microsoft Azure functions runtime.</description>
<url>https://azure.microsoft.com/en-us/services/functions</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:https://github.com/Azure/azure-functions-java-worker</connection>
<developerConnection>scm:git:[email protected]:Azure/azure-functions-java-worker</developerConnection>
<url>https://github.com/Azure/azure-functions-java-worker</url>
<tag>HEAD</tag>
</scm>

<developers>
<developer>
<id>Microsoft</id>
<name>Microsoft Corporation</name>
</developer>
</developers>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<name>Sonatype Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<uniqueVersion>true</uniqueVersion>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>

<repositories>
<repository>
<id>maven.snapshots</id>
<name>Maven Central Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-core-library</artifactId>
<version>1.1.0</version>
<scope>compile</scope>
</dependency>
<!-- test -->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.2.0</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<workingDirectory>target</workingDirectory>
<systemProperties>
<property>
<name>testing-project-jar</name>
<value>${project.artifactId}-${project.version}-tests.jar</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>

</project>




Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.microsoft.azure.functions.annotation;

import org.junit.Before;
import org.junit.Test;
import org.reflections.Reflections;

import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import static junit.framework.TestCase.assertTrue;

/**
* Unit tests that enforce annotation contracts and conventions for Functions
*/
public class BindingTest {
private static Set<Class<?>> annotations;
private static String[] bindingAnnotationSuffix = new String[] { "Input", "Output", "Trigger" };

@Test
public void every_binding_annotation_should_have_name_method() {
final String methodName = "name";

for (Class<?> annotation : annotations) {
Optional<Method> method = findMethod(annotation, methodName);
assertTrue(method.isPresent());
}
}

@Test
public void every_binding_annotation_should_have_dataType_method() {
final String methodName = "dataType";

for (Class<?> annotation : annotations) {
Optional<Method> method = findMethod(annotation, methodName);
assertTrue(method.isPresent());
}
}

/**
* find all annotation bindings based on annotation suffix conventions defined in bindingAnnotationSuffix array
*/
@Before
public void findAllFunctionParameterBindingsInCore() {
annotations = new Reflections(BindingTest.class.getPackage().getName())
.getTypesAnnotatedWith(Target.class)
.stream()
.filter(t -> t.getSimpleName().endsWith(bindingAnnotationSuffix[0]) ||
t.getSimpleName().endsWith(bindingAnnotationSuffix[1]) ||
t.getSimpleName().endsWith(bindingAnnotationSuffix[2])).collect(Collectors.toSet());
}

private Optional<Method> findMethod(Class<?> type, String name) {
return Arrays.stream(type.getMethods()).filter(m -> m.getName().equals(name)).findAny();
}
}
151 changes: 151 additions & 0 deletions azure-functions-java-library/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-library</artifactId>
<version>2.2.0</version>
<packaging>jar</packaging>
<parent>
<groupId>com.microsoft.maven</groupId>
<artifactId>java-8-parent</artifactId>
<version>8.0.1</version>
<relativePath></relativePath>
</parent>

<name>Microsoft Azure Functions Java Core Types</name>
<description>This package contains all Java interfaces and annotations to interact with Microsoft Azure functions runtime.</description>
<url>https://azure.microsoft.com/en-us/services/functions</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<licenses>
<license>
<name>MIT License</name>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:https://github.com/Azure/azure-functions-java-worker</connection>
<developerConnection>scm:git:[email protected]:Azure/azure-functions-java-worker</developerConnection>
<url>https://github.com/Azure/azure-functions-java-worker</url>
<tag>HEAD</tag>
</scm>

<developers>
<developer>
<id>pgopa</id>
<name>Pragna Gopa</name>
<email>[email protected]</email>
</developer>
<developer>
<id>xscript</id>
<name>Kevin Zhao</name>
<email>[email protected]</email>
</developer>
</developers>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<name>Sonatype Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<uniqueVersion>true</uniqueVersion>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>

<repositories>
<repository>
<id>maven.snapshots</id>
<name>Maven Central Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-core-library</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
<!-- test -->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.2.0</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<workingDirectory>${project.build.directory}</workingDirectory>
<systemProperties>
<property>
<name>testing-project-jar</name>
<value>${project.artifactId}-${project.version}-tests.jar</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
* context.getLogger().info("Name: " + filename + ", Size: " + content.length + " bytes");
* }</pre>
*
* @see com.microsoft.azure.functions.annotation.BindingName
* @since 1.0.0
*/
@Retention(RetentionPolicy.RUNTIME)
Expand Down
Loading